【问题标题】:Using X.509 Certificate with UserName clientCredentialType将 X.509 证书与用户名 clientCredentialType 一起使用
【发布时间】:2012-03-16 21:04:34
【问题描述】:

我正在创建一个需要代理用户名和密码的 WCF 服务,为此我需要提供一个服务证书,我已为其提供了我们公司的有效 Verisign 证书。

我遇到的问题是,每当我使用以下配置时,我都会收到一条错误消息“未提供服务证书。在 ServiceCredentials 中指定服务证书。”

<system.serviceModel>
<serviceHostingEnvironment multipleSiteBindingsEnabled="false" />
<behaviors>
  <serviceBehaviors>
    <behavior name="WSBehaviour">
      <serviceMetadata httpGetEnabled="true" />
      <serviceDebug includeExceptionDetailInFaults="true" />
      <serviceCredentials>
        <serviceCertificate findValue="devstage1.vcg-online.net" x509FindType="FindBySubjectName" storeLocation="LocalMachine" storeName="TrustedPublisher" />
        <userNameAuthentication userNamePasswordValidationMode="Custom" customUserNamePasswordValidatorType="Acre.IntegrationService.CustomValidator, Acre.IntegrationService" />
      </serviceCredentials>
    </behavior>
  </serviceBehaviors>
</behaviors>
<services>
  <service name="Acre.IntegrationService.IntegrationService" behaviorConfiguration="WSBehaviour">

    <endpoint address="http://localhost/Acre.IntegrationService/IntegrationService.svc"
              binding="wsHttpBinding"
              bindingConfiguration="WSBinding"
              contract="Acre.IntegrationService.IIntegrationService"
              name="WS" />

    <endpoint address="mex"
              binding="mexHttpBinding"
              contract="IMetadataExchange" />

  </service>
</services>
<bindings>
  <wsHttpBinding>
    <binding name="WSBinding" allowCookies="false">
      <security mode="Message">
        <message clientCredentialType="UserName" negotiateServiceCredential="true" />
      </security>
    </binding>
  </wsHttpBinding>
</bindings>

更新配置

我已在控制台中使用 mmc.exe 将证书安装到以下路径

证书(本地计算机)/个人/证书/ 证书(本地计算机)/受信任的根证书颁发机构/证书/ 证书(本地计算机)/受信任的发布者/证书/

我已经搜索了互联网,但找不到明确的解决方案。 有人可以帮忙吗?

【问题讨论】:

  • 注意:证书也安装在当前用户和计算机下的那些位置。并已导入IIS
  • 你应该指定一个需要使用的serviceCertificate。您是否尝试通过传输通道使用 SSL 保护服务?
  • 我在服务行为中指定一个证书,是的 SSL over transport 用于自定义授权...忽略这一点,我刚刚注意到我正在使用客户端证书,我将更改它并尝试它
  • 我将配置更改为有一个 serviceCertificate,现在错误是 KeySet 不存在
  • 它是自签名证书吗?另外请更新您的配置

标签: wcf wcf-security x509certificate


【解决方案1】:

我已经设法解决了这个问题,@Rajesh 你是正确的,clientCertificate 需要是 serverCertificate,纠正了错误,没有找到证书,谢谢。计算机用户的计算机上已经安装了证书。

密钥集的问题是证书没有设置正确的帐户权限。我更改了权限以允许 IIS_USRS 访问证书,现在它已修复

【讨论】:

    猜你喜欢
    • 2020-10-05
    • 2014-09-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-05-05
    • 2012-07-22
    • 1970-01-01
    相关资源
    最近更新 更多