19

8.1 用に構築された Windows Phone アプリがあり、タスクの 1 つはクライアント サーバー証明書のシナリオでした。私のアプリは正常に動作し、クライアント証明書を送信してサーバーにログインできました。ただし、Windows 8.10.14xxxx にアップグレードした後は、それは不可能でした。Wireshark トレースを取得しましたが、証明書が送信されないようです。メッセージの内容の長さは 0 です。

HttpClient.SendAsync(await) とを使用HttpBaseProtocolFilterして、証明書を入力します。アップグレード前は完璧に機能していました。

何か案が?何かが壊れていますか?

まず、pfxをインストールしています

async private void btnInstall_Click(object sender, RoutedEventArgs e)
{
    //Install the self signed client cert to the user certificate store

    string CACertificate = null;
    try
    {
        Uri uri = new Uri("ms-appx:///certificates/test.pfx");
        var file = await Windows.Storage.StorageFile.GetFileFromApplicationUriAsync(uri);
        IBuffer buffer = await FileIO.ReadBufferAsync(file);
        using (DataReader dataReader = DataReader.FromBuffer(buffer))
        {
            byte[] bytes = new byte[buffer.Length];
            dataReader.ReadBytes(bytes);
            // convert to Base64 for using with ImportPfx
            CACertificate = System.Convert.ToBase64String(bytes);
        }
        await CertificateEnrollmentManager.UserCertificateEnrollmentManager.ImportPfxDataAsync(
            CACertificate,
            "xxxxx",
            ExportOption.Exportable,
            KeyProtectionLevel.NoConsent,
            InstallOptions.None,
            "ClientCert1");


    }
    catch (Exception ex)
    {
        //;
    }
}

次に、サービスを呼び出しています

string serviceURL = "https://my.web.services";
Certificate cert = null;

CertificateQuery query = new CertificateQuery();
query.FriendlyName = "ClientCert1";
IReadOnlyCollection<Certificate> certs = await CertificateStores.FindAllAsync(query);

HttpBaseProtocolFilter bpf = new HttpBaseProtocolFilter();
//if you install the CA you don't need to ignore the ServerCertificate Errors
//bpf.IgnorableServerCertificateErrors.Add(ChainValidationResult.Untrusted);

if (certs.Count > 0)
{
    cert = certs.ElementAt(0);
    bpf.ClientCertificate = cert;
}

HttpClient httpClient = new HttpClient(bpf);
try
{

    var response = await httpClient.GetInputStreamAsync(new Uri(serviceURL));
    //take data
}
catch (Exception ex)
{              
    //0x80072F0D 
}

Windows phone0x80072F0Dで実行しているときは、常に例外 ( ) を使用しています。8.10.14xxxx私のコードは更新前に機能していましたが、現在は常にこのリターン コードを取得しています。証明書は httpClient にロードされます。デバッガーでアプリを停止すると、証明書があるように見えますが、0x800072F0Dおそらく証明書が送信されていないことを意味しますか???

シナリオには中間認証局があります。その証明書は pfx に含まれています。どういうわけかこれをインストールする必要がありますか?

4

1 に答える 1