c# - WCF service dns identity on client doesn't work -
trying communicate soap service via https. service has certificate. works ok, if install certificate local storage or write it's encoded content in config as
<certificate encodedvalue="ccbf......"/>
but don't want have hard reference in client service certificate data, due expire , changed. want accept service certificate cn or someway that.
according msdn client.endpoint.identity.dns value can used in such case. if dns.value==cn in service certificate, connection should ok.
but doesn't.
when open connection, exception:
client.endpoint.contract.protectionlevel = system.net.security.protectionlevel.sign; client.open();
additional information: service certificate not provided target 'https://sss.myhost.com'. specify service certificate in 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>
i believe you'll have implement own certificate validation.
<behavior name="credentialconfiguration"> <clientcredentials> <servicecertificate> <authentication certificatevalidationmode="custom" customcertificatevalidatortype="your validator"/> </servicecertificate> </clientcredentials> </behavior>
where validator assembly-qualified type name of class implements x509certificatevalidator
. there have full freedom of validating whatever want - cn, thumbprint, etc.
Comments
Post a Comment