Client Certificates Windows Phone 8.1

前端 未结 1 439
时光说笑
时光说笑 2020-12-18 07:32

Does Windows Phone 8.1 support adding a client certificate to an HTTP web request? I\'m trying to do something similar to the following, but I can\'t seem to determine what

相关标签:
1条回答
  • 2020-12-18 08:19

    I assume that you have already put the client certificate in app certificate store. If not this is how you will have to do that 1) Download the PFX file. 2) Install it in the App's certificate store using the following way

    await CertificateEnrollmentManager.ImportPfxDataAsync(certString, "Your_PFX_Password", ExportOption.Exportable, KeyProtectionLevel.NoConsent, InstallOptions.None, friendlyName);
    

    3) The next step is to look for the certificate in certificate store. This is done as below

    CertificateQuery certQuery = new CertificateQuery();
    certQuery.FriendlyName = friendlyName;
    IReadOnlyList<Certificate> certs = await CertificateStores.FindAllAsync(certQuery)
    

    The certs[0] will have the certificate

    4) To attach the certificate to HTTP request

    HttpBaseProtocolFilter protolFilter = new HttpBaseProtocolFilter();
    protolFilter.ClientCertificate = certs[0] //from previous step
    HttpClient client = new HttpClient(protolFilter)
    

    Point to note is you should not use System.Net.htpp.HttpClient. Instead you should you Windows.Web.Http.HttpClient.

    0 讨论(0)
提交回复
热议问题