[英]WCF service dns identity on client doesn't work
尝试通过https与某些SOAP服务进行通信。 服务有证书。 如果我将此证书安装到本地存储中或将其编码内容写入config中,一切正常
<certificate encodedValue="CCBF......"/>
但是我不想在客户端中使用硬引用来为证书数据提供服务,因为它将很快过期并且将被更改。 我想接受CN或类似的服务证明。
根据MSDN,在这种情况下,可以使用client.endpoint.identity.dns值。 因此,如果服务证书中的dns.value == CN,则连接应该可以。
但事实并非如此。
打开连接时,出现异常:
client.Endpoint.Contract.ProtectionLevel = System.Net.Security.ProtectionLevel.Sign;
client.Open();
附加信息:未为目标“ https://sss.myhost.com ”提供服务证书。 在ClientCredentials中指定服务证书。
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
<system.serviceModel>
<bindings>
<customBinding>
<binding>
<security authenticationMode="MutualCertificate"
enableUnsecuredResponse="true"
messageSecurityVersion="WSSecurity10WSTrustFebruary2005WSSecureConversationFebruary2005WSSecurityPolicy11BasicSecurityProfile10">
<secureConversationBootstrap />
</security>
<textMessageEncoding messageVersion="Soap11" />
<httpsTransport />
</binding>
</customBinding>
</bindings>
<behaviors>
<endpointBehaviors>
<behavior>
<clientCredentials>
<clientCertificate findValue="Foo" storeName="My" storeLocation="CurrentUser" x509FindType="FindByIssuerName"/>
<serviceCertificate>
<!--<defaultCertificate storeLocation="LocalMachine" x509FindType="FindByIssuerName" storeName="Root" findValue="MyIssuerName" />-->
</serviceCertificate>
</clientCredentials>
</behavior>
</endpointBehaviors>
</behaviors>
<client>
<endpoint address="https://sss.myhost.com"
binding="customBinding"
contract="RS.InstanceManagerPortType" name="InstanceManagerPort">
<identity>
<!--<certificate encodedValue="CCBF......"/>-->
<dns value="*.myhost.com"/>
</identity>
</endpoint>
</client>
</system.serviceModel>
</configuration>
我相信您将必须实施自己的证书验证。
<behavior name="credentialConfiguration">
<clientCredentials>
<serviceCertificate>
<authentication
certificateValidationMode="Custom"
customCertificateValidatorType="YOUR VALIDATOR"/>
</serviceCertificate>
</clientCredentials>
</behavior>
其中,您的VALIDATOR是实现X509CertificateValidator
的类的程序集限定类型名称。 在那里,您可以完全自由地验证所需的内容-CN,指纹等。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.