安装客户端证书后,我收到异常“对象仅包含密钥对的公共部分。还必须提供私钥”。我的应用程序是在 ASP.NET 平台上运行的 VC#.NET 应用程序。该应用程序还使用 WSE 2.0 导入证书以发出 SOAP 请求。
经过研究,我发现此异常属于 System.Security.Cryptography.CryptographyException 类型。
我非常肯定我的所有 WSE 设置都配置正确,因为我能够通过主题可分辨名称找到类似的证书。任何想法将不胜感激。
Upon installation of a client side certificate, I am getting the exception "Object contains only the public half of a key pair. A private key must also be provided". My application is a VC#.NET application running over an ASP.NET platform. The application also uses WSE 2.0 to import certificates into making SOAP requests.
Upon research, I've found that this exception is of type System.Security.Cryptography.CryptographicException.
I am pretty positive all my WSE settings are configured correctly, since I was able to find a similar certificate by subject-distinguished-name. Any ideas will be greatly appreciated.
发布评论
评论(3)
我最近遇到了同样的问题。我发现这里有一个对我有用的解释。具体来说,是私钥的权限。完整信息复制如下。
I was recently having the same problem. I found one explanation here that worked for me. Specifically, the permissions for the private key. The full info is copied below.
根据我的经验,失败可能有两个原因。
谢谢。
As per my experience it could be failing because of two reasons.
Thanks.
在遇到相同的异常:System.Security.Cryptography.CryptographicException,对象仅包含密钥对的公共一半后,我证明了替代方案,但不太理想的解决方案。
情况:证书/密钥查找在 Visual Studio IIS Express 中运行良好,但是当 Web 应用程序在正确的 IIS 服务下运行时,我总是收到“仅包含密钥对的公共部分”异常。
我使用 WSE3 CertificateTool 来定位文件系统上的私钥部分,并尝试根据上述答案调整用户权限设置以授予 ASP 用户权限。
我最终的修复(不太完美)是创建一个特定于我的 Web 服务代码的新 IIS 应用程序池,并将池运行的用户身份设置为证书 + 私钥的本地计算机所有者。
我安装证书的最终位置是“本地计算机/受信任的人”。
使用 WSE3 CustomPolicyAssertion、C# .NET:
更新应用程序池标识后,更改应用程序池所有者时无需覆盖私钥文件。
After encountering the same exception: System.Security.Cryptography.CryptographicException, Object contains only the public half of a key pair, I proofed an alternative, but less optimal solution.
Situation: Certificate / key look up worked great inside of Visual Studio IIS Express, but while the Web Application was running under the proper IIS service, I always received the 'Contains only public half of key pair' exception.
I used the WSE3 CertificateTool to locate the private key section on the filesystem and attempted at length to adjust the user permission settings to give the ASP user permissions as per the above answer.
My eventual fix, which was not pretty, was to create a new IIS Application Pool specific to my Web service code and set the user Identity the pool runs as the Local machine owner of the certificate + private key.
The final location I installed the certificate in was "Local Computer / Trusted People".
Using WSE3 CustomPolicyAssertion, C# .NET:
After updating the App Pool Identity, no private key file overrides were necessary when changing the application pool owner.