2017-12-15 39 views
-1

수동으로 pfx 확장 인증서를 내 컴퓨터에 설치했습니다. 어떻게 방법이 있지만 Windows.Web.Http.HttpClient에 PFX 설치된 인증서를 추가하는 방법

var myFilter = new HttpBaseProtocolFilter(); 
    CertificateQuery certQuery = new Windows.Security.Cryptography.Certificates.CertificateQuery(); 
    certQuery.FriendlyName = "TEST"; // This is the friendly name of the certificate that was just installed. 
    IReadOnlyList<Certificate> certificates = await Windows.Security.Cryptography.Certificates.CertificateStores.FindAllAsync(certQuery); 
    var client = new HttpClient(certificates[0]); 

누군가가 HttpClient를 수동으로 설치 인증서를 추가하는 방법이 나를 도와 줄 수

행운을 다음 시도 얻을

Windows.Web.Http.HttpClient

에 전달하는 방법?

답변

-1
X509Store store = new X509Store(StoreName.My, StoreLocation.CurrentUser); 
store.Open(OpenFlags.ReadOnly); 
X509Certificate2Collection certs = store.Certificates.Find(
    X509FindType.FindByIssuerName, "TEST", false); 
    //Change FindType to your liking, it doesn't support FriendlyName, 
    //maybe use your method? 

WebRequestHandler handler = new WebRequestHandler(); 
X509Certificate2 certificate = GetMyX509Certificate(); 
handler.ClientCertificates.Add(certificate); 
HttpClient client = new HttpClient(handler); 

여기 있습니다. 어쩌면 Add 메서드에 대한 인증서를 사용할 수 있지만 호환되는지 여부를 알 수 없습니다.

+0

UWP 용 system.net.httpclient가 아닙니다 .Web.Http.HttpClient – Ragavan