私の C# .net アプリケーションは HTTPS Web サービスを使用しています。証明書の有効期限が近づいているため、受け取った新しい証明書 (javasdks の keytool を使用して .p12 に変換した .jks ファイル) で更新しようとしています。方法を知っているので、これは簡単だと思いましたが、うまくいきません。
私がこれまでに行ったこと:
- 証明書を CURRENT_USER\Personal にインポートしました
- 証明書を LOCAL_MACHINE\Personal にインポートしました
- winhttpcertcfg ツールを使用して、証明書の秘密キーへの正しいユーザー (apppoolidentity) アクセスを指定します。以下は、証明書に対する権限のリストです。
- findprivatekey ツールを使用して、実際のキー ファイルも特定し、apppoolidentity にアクセス権を付与しました。(必死で)。 - C:\Program Files (x86)\Windows Resource Kits\Tools>winhttpcertcfg -l -c LOCAL_MACHINE\My -s "9000 - Blabla" Microsoft (R) WinHTTP Certificate Configuration Tool Copyright (C) Microsoft Corporation 2001. - 一致する証明書: CN=9000 - Blabla C=NO L="c/o Blabla AS, Blablaaddress" OU=957839827 OID.1.2.240.111111.1.9.8=12345678 OID.1.2.240.111111.1.9.2=Blabla Test O= BlaBla AS OU=MULTI-ALLOWED - 秘密キーにアクセスできる追加のアカウントとグループには、次のものがあります。 BUILTIN\Administrators NT AUTHORITY\SYSTEM IIS APPPOOL\ASP.NET v4.0 BUILTIN\Users NT AUTHORITY\NETWORK SERVICE DIGITROLLDMZ\IIS_WPG 
アクセスしているURLは次のようになります。
https://test.blabla.com/blabla-5.0/services/Blabla?wsdl
...サーバーのWebブラウザーからアクセスすると、証明書を選択し、新しい証明書を選択すると、問題はありませんが、緑とSSLが順番に表示されますが、アプリケーションコードは次のようになります。
public static blabla.service.NettforhandlerService getNettforhandlerService(string applicationPath) 
    {
    blabla.service.NettforhandlerService service = new blabla.service.NettforhandlerService();
    if (System.Configuration.ConfigurationManager.AppSettings["CertificateSerialNumber"] != null && System.Configuration.ConfigurationManager.AppSettings["CertificateSerialNumber"].Length > 0)
    {
        string serviceurl = service.Url;
        X509Store store = new X509Store(StoreName.Root, StoreLocation.LocalMachine);
        store.Open(OpenFlags.ReadOnly);
        X509Certificate2Collection col = store.Certificates.Find(X509FindType.FindBySerialNumber, System.Configuration.ConfigurationManager.AppSettings["CertificateSerialNumber"], true);
        ServicePointManager.Expect100Continue = true;
        ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3;
        ServicePointManager.CertificatePolicy = new TrustHBSCertificatePolicy();
        service.ClientCertificates.Add(col[0]);
    }
    return service;
    }
このエラーのみを出力します:
The request was aborted: Could not create SSL/TLS secure channel.
... web.config にトレース/デバッグ情報を追加しました。エラーからわかったのは次のとおりです。
[Public Key]
  Algorithm: RSA
  Length: 2048
  Key Blob: 30 82 01 0a 02 82 01 01 00 8e a6 72 c2 e1 67 16 e2 be be c3 30 89 8d bb 57 0b 48 f8 1d 09 b1 e3 26 42 c9 45 9e 02 b2 43 49 16 81 94 1b 18 d6 6d ef ....
System.Net Information: 0 : [15624] SecureChannel#32061089 - Certificate is of type X509Certificate2 and contains the private key.
System.Net Information: 0 : [15624] AcquireCredentialsHandle(package = Microsoft Unified Security Protocol Provider, intent  = Outbound, scc     = System.Net.SecureCredential)
System.Net Error: 0 : [15624] AcquireCredentialsHandle() failed with error 0X8009030D.
System.Net Information: 0 : [15624] AcquireCredentialsHandle(package = Microsoft Unified Security Protocol Provider, intent  = Outbound, scc     = System.Net.SecureCredential)
System.Net Error: 0 : [15624] AcquireCredentialsHandle() failed with error 0X8009030D.
System.Net.Sockets Verbose: 0 : [15624] Socket#38259205::Dispose()
System.Net Error: 0 : [15624] Exception in the HttpWebRequest#54558071:: - The request was aborted: Could not create SSL/TLS secure channel.
System.Net Error: 0 : [15624] Exception in the HttpWebRequest#54558071::GetResponse - The request was aborted: Could not create SSL/TLS secure channel.
System.Net Verbose: 0 : [15624] 
これは、正しいユーザー/ID に (winhttpcertcfg から) 証明書へのアクセス権が与えられていないように見えますが、そうであると確信しています。そのため、ここで途方に暮れています。
深刻な https-certificate/web-service スキルを持つ誰かがここで私を助けてくれることを願っています:-)
ありがとう。
よろしく、 Jørgen E.
edit1: タイトルをより正確なものに変更しました。edit2: 新しい情報:
In EventViewer/Windows Logs/Security there is an event "Audit Failure" connected to this:
Cryptographic operation.
Subject:
    Security ID:        IIS APPPOOL\ASP.NET v4.0
    Account Name:       ASP.NET v4.0
    Account Domain:     IIS APPPOOL
    Logon ID:       0x32498
Cryptographic Parameters:
    Provider Name:  Microsoft Software Key Storage Provider
    Algorithm Name: Not Available.
    Key Name:   {00E1A3F5-7400-41CA-8290-02983473AEAF}
    Key Type:   Machine key.
Cryptographic Operation:
    Operation:  Open Key.
    Return Code:    0x80090010