Wednesday, September 25, 2013

transport layer security

// transport layer security -client side

ServiceReference1.ServiceClient s = new ServiceReference1.ServiceClient();
s.ClientCredentials.UserName.UserName = "windows";
s.ClientCredentials.UserName.Password = "omomsandeepkaran";
Response.Write(s.GetData()); 

// web config

<system.serviceModel>

<bindings>
    <wsHttpBinding>
       <binding name ="narang">
        <security mode ="Transport">
          <transport clientCredentialType ="Basic">

          </transport>
       </security>
      </binding>
     </wsHttpBinding>
</bindings>

<services>

<service name="Service" behaviorConfiguration="ServiceBehavior">
<!-- Service Endpoints -->
<endpoint address="" binding="wsHttpBinding" bindingConfiguration ="narang" contract="IService">
<!--
Upon deployment, the following identity element should be removed or replaced to reflect the identity under which the deployed service runs. If removed, WCF will infer an appropriate identity automatically.
-->
<identity>
   <dns value="localhost"/>
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="ServiceBehavior">
<!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
<serviceMetadata httpGetEnabled="true"/>
<!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>

==========================
//Transport layer security 
<wsHttpBinding>
<binding name ="narang">
<security mode ="Transport">
<transport clientCredentialType ="Basic">

</transport>
</security>
</binding>
</wsHttpBinding>
// Attach with EndPoint
<endpoint address="" binding="wsHttpBinding" bindingConfiguration ="narang" contract="IService">

step-2

Go to IIS --create certificate

step-3
Add HTTPS and assign ceritificate name

step-4 netsh http show sslcert
netsh http delete sslcert ipport=0..0.0.0:8080

netsh http add sslcert ipport=0.0.0.0:8080 certhash=2b626efa63a083bbf868d2b8dfc2bcab263d9857 appid={4B04E6AD-E432-40EB-9A11-9081F5DDEC88}

No comments:

Post a Comment