2017-12-11 25 views
0

OpenSSL을 사용하여 X509 인증서를 만들었습니다. .NET Core 2.0에서 X509Certificate2 클래스의 Import 메서드를 사용하여로드하려고합니다. 디스크의 .Net 코어에서 X509 인증서로드

var cert = new X509Certificate2(); 
cert.Import(_path); 

그러나

다음과 같은 예외가 던져 :

System.PlatformNotSupportedException : X509Certificate is immutable on this 
platform. Use the equivalent constructor instead. 

내가 사용해야하는 생성자/디스크에서이 인증서를로드하는 올바른 방법은 무엇입니까?

+0

당신이 구현되지 .NET 핵심 수입의 코드를 찾고 새로운 X509Certificate2 (certificateAsByteArray)을 해봤 사용할 수 있습니다 https://github.com/dotnet/corefx/blob/4617dd43596aabb0a109049dcea124fae5ba743e/ src/System.Security.Cryptography.X509Certificates/src/System/Security/Cryptography/X509Certificates/X509Certificate2.cs – RaniDevpr

+0

이 작동합니다 - 감사합니다 – BlackSpy

답변

3

당신은

var x509 = new X509Certificate2(File.ReadAllBytes(_path)); 
+0

결과! 정말 고마워 – BlackSpy