Click here to Skip to main content
15,885,537 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Getting below mentioned error while implementing WCF certificate authentication

Secure channel cannot be opened because security negotiation with the remote endpoint has failed. This may be due to absent or incorrectly specified EndpointIdentity in the EndpointAddress used to create the channel.

I have already put the certificates in Trusted People.

It looks like identity problem and I have tried setting the identity both in service and client config but still it didn't work.

Service Config
________________
XML
<bindings>
      <wsHttpBinding>
        <binding name="WSHTTP">
          <security mode="Message">
            <message clientCredentialType="Certificate" />
          </security>
        </binding>
      </wsHttpBinding>
    </bindings>


XML
<service name="WCFCertificateAuth.Service1">
        <endpoint address="" binding="wsHttpBinding" bindingConfiguration=""
          bindingName="WSHTTP" contract="WCFCertificateAuth.IService1">
          <!--<identity>
            <dns value="WCfServer"/>
          </identity>-->
        </endpoint>
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />


XML
<behaviors>
      <serviceBehaviors>
        <behavior>
          <serviceMetadata httpGetEnabled="True" httpsGetEnabled="True"/>
          <serviceDebug includeExceptionDetailInFaults="False" />
          <serviceCredentials>
            <clientCertificate>
              <authentication certificateValidationMode="PeerTrust"/>
            </clientCertificate>
            <serviceCertificate findValue="WCfServer" storeLocation="CurrentUser" storeName="TrustedPeople" x509FindType="FindBySubjectName"/>
          </serviceCredentials>
        </behavior>
      </serviceBehaviors>
    </behaviors>



Client Config
_______________
XML
<bindings>
           <wsHttpBinding>
               <binding name="WSHTTP_IService1" sendTimeout="00:05:00">
                   <security mode="Message">
                       <message clientCredentialType="Certificate" />
                   </security>
               </binding>
           </wsHttpBinding>
       </bindings>


XML
<client>
 <endpoint address="http://localhost:8733/WCFCertificateAuth/Service1/"
                binding="wsHttpBinding" bindingConfiguration="WSHTTP_IService1"
                contract="IService1" name="WSHTTP_IService1">
                <identity>
                    <dns value="WCfServer" />
                </identity>
 </endpoint>
 </client>


XML
<behaviors>
        <endpointBehaviors>
          <behavior>
            <clientCredentials>
              <serviceCertificate>
                <authentication certificateValidationMode="PeerTrust"/>
              </serviceCertificate>
              <clientCertificate findValue="WCfClient" storeLocation="CurrentUser" storeName="TrustedPeople" x509FindType="FindBySubjectName"/> 
            </clientCredentials>
          </behavior>
        </endpointBehaviors>
</behaviors>
Posted
Updated 24-Jun-15 0:01am
v2

1 solution

HI,
In Client config,

Use machine/server full name instead of localhost and remove identity tag.

XML
<client>
 <endpoint address="http://ServerName:8733/WCFCertificateAuth/Service1/ServiceName.svc">
                binding="wsHttpBinding" bindingConfiguration="WSHTTP_IService1"
                contract="IService1" name="WSHTTP_IService1">        
 </endpoint>
 </client>


TIA
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900