我的C#.net应用程序正在使用HTTPS Web服务.由于证书现在即将到期,我正在尝试使用我已经给出的新版本更新它(我使用javasdks的keytool转换为.p12的.jks文件).我认为这很容易,因为我知道该怎么做,但它不会合作.
到目前为止我做了什么:
使用findprivatekey工具,我还找到了实际的密钥文件,并给出了apppoolidentity访问权限.(无奈之下).
C:\ Program Files(x86)\ Windows资源工具包\工具> winhttpcertcfg -l -c LOCAL_MACHINE\My -s"9000 - Blabla"Microsoft(R)WinHTTP证书配置工具版权所有(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 =多次允许
可以访问私钥的其他帐户和组包括:BUILTIN\Administrators NT AUTHORITY\SYSTEM IIS APPPOOL\ASP.NET v4.0 BUILTIN\Users NT AUTHORITY\NETWORK SERVICE DIGITROLLDMZ\IIS_WPG
我正在访问的网址看起来像这样:
https://test.blabla.com/blabla-5.0/services/Blabla?wsdl
Run Code Online (Sandbox Code Playgroud)
...如果我从服务器网络浏览器访问它,我会选择证书,我选择新的证书,它说它没关系,绿色和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;
}
Run Code Online (Sandbox Code Playgroud)
仅输出此错误:
The request was aborted: Could not create SSL/TLS secure channel.
Run Code Online (Sandbox Code Playgroud)
...我已经向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]
Run Code Online (Sandbox Code Playgroud)
我知道这看起来像正确的用户/身份没有获得证书的访问权限(来自winhttpcertcfg),但我很确定它有,这就是为什么我在这里,
希望有一些认真的https-certificate/web-service -skills的人可以帮助我:-)
谢谢.
此致,JørgenE.
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
Run Code Online (Sandbox Code Playgroud)
Dar*_*rer 12
从日志中提取的内容不多,但......
Google-fu产生以下结果:0x80090010很可能是证书访问错误.
由此,我得出结论,您需要为SSL证书私钥设置权限,以便IIS可以访问它.请参阅:http: //www.dotnetnoob.com/2011/01/how-to-give-iis-access-to-private-keys.html
与另一个选项类似的问题:请求已中止:无法创建SSL/TLS安全通道
| 归档时间: |
|
| 查看次数: |
46163 次 |
| 最近记录: |