Click here to Skip to main content
15,890,845 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello team,

I am designing application in WPF and I want to connect wcf service through 2 way ssl authentication..

C#
I have generated client-server  certificate and pfx file. 

I have import service certificate on IIS and client certificate on console root .
but still I am getting many error like

C#
The HTTP request is unauthorized with client authentication scheme 'Anonymous'. The authentication header received from the server was ''.




this is my config at client side

XML
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <startup>
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />

  </startup>

  <system.serviceModel>
    <bindings>
      <wsHttpBinding>
        <binding name="WSHttpBinding_IBTA_Service">
          <security mode="Transport">
            <transport clientCredentialType="Certificate" />
          </security>
        </binding>
      </wsHttpBinding>
    </bindings>
    <client>
      <endpoint address="https://172.16.50.146:12466/BTA_Service.svc"
        binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IBTA_Service"
        contract="BTA_Service.IBTA_Service" name="WSHttpBinding_IBTA_Service " behaviorConfiguration="EndpointBehavior" />

     
    </client>
    <behaviors>
      <endpointBehaviors>
            <behavior name="EndpointBehavior">
              <clientCredentials>
                <clientCertificate storeLocation="LocalMachine"
                                   storeName="My"
                                   x509FindType="FindByThumbprint"
                                   findValue="3a396124e4435f661d8b211ea5ae118c132f5b34"/>
              </clientCredentials>
            </behavior>
          </endpointBehaviors>
        </behaviors>
  </system.serviceModel>
 
   

  
</configuration>


Service level config is

XML
<?xml version="1.0"?>
<configuration>
  <!--<system.diagnostics>
    <sources>
      <source propagateActivity="true" name="System.ServiceModel" switchValue="Warning,ActivityTracing">
        <listeners>
          <add type="System.Diagnostics.DefaultTraceListener" name="Default">
            <filter type="" />
          </add>
          <add name="ServiceModelTraceListener">
            <filter type="" />
          </add>
        </listeners>
      </source>
    </sources>
    <sharedListeners>
      <add initializeData="d:\gallello\gallellomvc\bta_wcf_service\web_tracelog.svclog"
        type="System.Diagnostics.XmlWriterTraceListener, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
        name="ServiceModelTraceListener" traceOutputOptions="Timestamp">
        <filter type="" />
      </add>
    </sharedListeners>
  </system.diagnostics>-->
  <system.web>
    <compilation debug="true" targetFramework="4.5"/>
    <pages controlRenderingCompatibilityVersion="4.0"/>
  </system.web>
  <connectionStrings>
    <add name="GDS_Connection" connectionString="F5XGWMkZIKnvmeKRLmDIs85gfShEhVsCb31D96JcpdLpltZWV3RBdpfwwCVPeOPz5EcrGS0/6c2N/s3sV9TIiNokGMnzuptigq6kJQHbpAWo6G0mBWlIag=="/>
  </connectionStrings>
  <system.serviceModel>
    <services>
      <service name="BTA_WCF_Service.BTA_Service">
        <endpoint address="" binding="wsHttpBinding" bindingConfiguration="TransportSecurity"
          contract="BTA_WCF_Service.IBTA_Service" />
        <endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange" />
      </service>
    </services>
    <bindings>
      <wsHttpBinding>
        <binding name="TransportSecurity">
          <security mode="Transport">
            <transport clientCredentialType="Certificate"/>
          </security>
        </binding>
      </wsHttpBinding>
    </bindings>
    <behaviors>
      <serviceBehaviors>
        <behavior>
          <serviceMetadata httpsGetEnabled="true"/>
          <serviceDebug includeExceptionDetailInFaults="false"/>
          <serviceCredentials>
            <serviceCertificate storeLocation="LocalMachine" x509FindType="FindBySubjectDistinguishedName" storeName="My" findValue="localhost"/>  
          </serviceCredentials>
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <serviceHostingEnvironment multipleSiteBindingsEnabled="True"/>
  </system.serviceModel>
  <system.webServer>
    <modules runAllManagedModulesForAllRequests="true"/>
    <!--
        To browse web app root directory during debugging, set the value below to true.
        Set to false before deployment to avoid disclosing web app folder information.
      -->
    <directoryBrowse enabled="true"/>
  </system.webServer>
</configuration>




Please give me brief explaining and demo solution for the same..

What I have tried:

ERROR :-
C#
The HTTP request is unauthorized with client authentication scheme 'Anonymous'. The authentication header received from the server was ''.
.

Please explain me entire process of 2 way ssl authentication
Posted
Updated 29-Nov-16 3:38am
v2

1 solution

Learn how to use google.

2-way ssl communications - Google Search[^]
 
Share this answer
 
Comments
Member 12597032 30-Nov-16 0:14am    
Hello Sir, I am able to use google very well..but I am facing problem, I have mention my error "The HTTP request is unauthorized with client authentication scheme 'Anonymous'. The authentication header received from the server was".

Please check my both config and assist me..
Thanks in advance.

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