如何在app.config中配置Digicert CNG证书

发布于 2025-02-09 05:18:10 字数 1667 浏览 1 评论 0原文

我们正在尝试配置由Digicert CA发行的客户提供的证书,以在WCF服务中进行身份验证。

不幸的是,我们需要运行的实用程序无法解析证书并给出意外错误:指定的提供商类型无效。错误。

似乎错误意味着证书的格式是CNG而不是CAPI,显然.NET 4及更高版本应该能够接受这些。但是我们仍然不确定如何将其输入app.config以使.NET识别证书。以下是带有端点证书身份验证的app.config文件内容。

有人可以提供一些建议吗?先感谢您。


    <behaviors>
      <endpointBehaviors>
        <behavior name="ClientCertificateBehavior">
          <clientCredentials>
            <clientCertificate findValue="2449997a30a8c9df29bd43c1eaa91cb47d89b0cb" storeLocation="LocalMachine" storeName="My" x509FindType="FindByThumbprint"/>            
            <serviceCertificate>
              <authentication certificateValidationMode="None" revocationMode="NoCheck"/>
            </serviceCertificate>
          </clientCredentials>
        </behavior>
      </endpointBehaviors>
    </behaviors>

    <client>
      <endpoint name="Download" address="http://mywebserviceurl.com/MobileService/WebService2.svc" behaviorConfiguration="ClientCertificateBehavior" binding="wsHttpBinding" bindingConfiguration="TheWsHttpBinding" contract="MyApp.FileClient.IDownloadService">
        <identity>
          <certificate encodedValue="*****"/>
        </identity>
      </endpoint>
    </client>

    <bindings>
      <wsHttpBinding>
        <binding name="TheWsHttpBinding">
          <security>
            <message clientCredentialType="Certificate"/>
          </security>
        </binding>
      </wsHttpBinding>
    </bindings>

  </system.serviceModel>

we're trying to configure a client-provided certificate which was issued by the DigiCert CA for authentication in a WCF service.

Unfortunately, the utility we need to run isn't able to parse the certificate and gives a Unexpected error: Invalid provider type specified. error.

It seems the error means that the format of the certificate is CNG instead of CAPI, and apparently .NET 4 and higher should be able to accept those. But we're still not sure how to enter that into app.config to make .NET recognize the certificate. Below is the app.config file contents with the endpoint certificate authentication.

Could someone please offer some advice? Thank you in advance.


    <behaviors>
      <endpointBehaviors>
        <behavior name="ClientCertificateBehavior">
          <clientCredentials>
            <clientCertificate findValue="2449997a30a8c9df29bd43c1eaa91cb47d89b0cb" storeLocation="LocalMachine" storeName="My" x509FindType="FindByThumbprint"/>            
            <serviceCertificate>
              <authentication certificateValidationMode="None" revocationMode="NoCheck"/>
            </serviceCertificate>
          </clientCredentials>
        </behavior>
      </endpointBehaviors>
    </behaviors>

    <client>
      <endpoint name="Download" address="http://mywebserviceurl.com/MobileService/WebService2.svc" behaviorConfiguration="ClientCertificateBehavior" binding="wsHttpBinding" bindingConfiguration="TheWsHttpBinding" contract="MyApp.FileClient.IDownloadService">
        <identity>
          <certificate encodedValue="*****"/>
        </identity>
      </endpoint>
    </client>

    <bindings>
      <wsHttpBinding>
        <binding name="TheWsHttpBinding">
          <security>
            <message clientCredentialType="Certificate"/>
          </security>
        </binding>
      </wsHttpBinding>
    </bindings>

  </system.serviceModel>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

幸福丶如此 2025-02-16 05:18:10

您可能正在使用.NET Framework 4.6.1或以下:

.NET Framework 4.6.1及更早版本不支持这些证书,因为它们使用旧版Cryptoapi处理CNG/KSP证书。这些证书与.NET Framework 4.6.1及更早版本的使用将导致例外。

Possibly you are using .NET Framework 4.6.1 or below:

.NET Framework 4.6.1 and earlier versions do not support these certificates because they use the legacy CryptoAPI to handle CNG/KSP certificates. The use of these certificates with .NET Framework 4.6.1 and earlier versions will cause an exception.
Source

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文