WCF获取证书编码值

AJM*_*AJM 12 .net wcf certificate

我正在使用我的WCF服务的证书,因此在web.Config中有一个编码值

<identity>
  <certificate encodedValue="large string!!!!!!!" />
</identity>
Run Code Online (Sandbox Code Playgroud)

该值是由Visual Studio在开发中使用我的测试证书生成的.

现在我正在部署我想获得由管理服务器的第三方维护的证书的编码值.

我知道使用如下的svcutil.exe工具会给我这个.

svcutil.exe http://servicename.svc
Run Code Online (Sandbox Code Playgroud)

我想知道的是

  1. 这是推荐的方法吗?
  2. 有没有办法做到这一点,我错过了

编辑:Visual Studio不可用,我无法移动证书,所以它必须是一个非VS解决方案

AJM*_*AJM 20

这可以通过将证书(通过IIS或证书管理单元)导出到.cer文件而不使用base64形式的私钥,然后在记事本中打开并将其复制并粘贴到encodedValue中来完成.

  • 请参阅http://bartwullems.blogspot.co.uk/2011/05/wcf-certificate-encodedvalue.html (4认同)

blo*_*art 0

如果它由第 3 方管理,则服务器证书将加载到 Windows 证书存储中并选择作为服务行为的一部分

在服务行为中,您可以通过以下方式选择它在端点上使用的证书

<behaviors>
  <serviceBehaviors>
    <behavior name="MyServiceBehavior">
      <serviceCredentials>
        <serviceCertificate findValue="CN=myhost.mydomain.org" />
      </serviceCredentials>
    </behavior>
  </serviceBehaviors>
</behaviors>
Run Code Online (Sandbox Code Playgroud)

该元素用于连接客户端。只需刷新客户端解决方案中代理的服务引用,并且应使用新证书的公共部分的编码值版本来更新身份元素。