WCF obtaining certificate encoded value

自古美人都是妖i 提交于 2019-12-20 08:46:12

问题


I am using a certificate with my WCF service so have an encoded value in the web.Config

<identity>
  <certificate encodedValue="large string!!!!!!!" />
</identity>

The value was generated by Visual studio in development using my test certificate.

Now I am deploying I want to get the encoded value for the certificate maintained by the third part who manage the server.

I know that using the svcutil.exe tool as follows will give me this.

svcutil.exe http://servicename.svc

What I want to know is

  1. Is this the recommended approach
  2. Are there any either ways to do this that I'm missing

EDIT: Visual Studio isn't available and I cant move the certificate so it will have to be a non VS solution


回答1:


This can be done by exporting the certificate (via IIS or Certificate Snap In) to a .cer file without the private key in base64 form, then opening in notepad and copying and pasting this into encodedValue




回答2:


If it's managed by a 3rd party then the server certificate is going to be loaded into the Windows certificate store and selected as part of the service behaviour

In the service behaviour you can select the certificate it uses on the endpoint by

<behaviors>
  <serviceBehaviors>
    <behavior name="MyServiceBehavior">
      <serviceCredentials>
        <serviceCertificate findValue="CN=myhost.mydomain.org" />
      </serviceCredentials>
    </behavior>
  </serviceBehaviors>
</behaviors>

The element is used for a connecting client. Simply refresh the service reference for the proxy in the client solution and the identity element should be updated with an encoded value version of the public parts of the new certificate.



来源:https://stackoverflow.com/questions/1199525/wcf-obtaining-certificate-encoded-value

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!