Configure a WCF Service for SSL

by Lynn Roth 19. January 2011 23:33

I’m in the process of setting up some web services at work and need to set them up for SSL.  Here are the steps I followed.  This process is based on http://msdn.microsoft.com/en-us/library/ms733791.aspx from Microsoft.  This just hits the main points for the next time I have to do it.

  1. Get a certificate.  I already have the wildcard cert installed on my machine (through ISS), so I am not going to do a step by step here.
  2. Choose the ip address and port.  I’m running this on a private IP and just running on standard port 443.  I”ll use 10.0.1.55 for this example.
  3. Get the certificate thumbnail (http://msdn.microsoft.com/en-us/library/ms734695.aspx)
    1. Find the Thumbnail in the certificate details and remove all the spaces.
  4. Check your current configuration
    1. netsh http show sslcert
  5. netsh http add sslcert ipport=10.0.1.55:443 certhash=0000000000003ed9cd0c315bbb6dc1c08da5e6 appid={00112233-4455-6677-8899-AABBCCDDEEFF}
    1. Use the thumbnail from step 3 for the certhash
    2. Use a GUID for the appid.  It apparently doesn’t matter which GUID you use.  I just created a new one. You could use http://createguid.com/.

That takes care of the server certificate configuration.  Now for the WCF config. I’m doing the config via the .config file on the server side, so that is what I will show here.

   1: <system.serviceModel>
   2:     <services>
   3:       <service name="FullServiceName"  behaviorConfiguration="ServiceBehavior">
   4:         <host>
   5:           <baseAddresses>
   6:             <add baseAddress="https://transfer.uri.com/Transfer"/>
   7:           </baseAddresses>
   8:         </host>
   9:         <endpoint address=""  binding="basicHttpBinding" bindingConfiguration="httpsStreaming" contract="Fully.Qualified.Contract.ITransfer" />
  10:         <endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange" />
  11:       </service>
  12:     </services>
  13:  
  14:     <bindings>
  15:       <basicHttpBinding>
  16:         <binding name="httpsStreaming"
  17:                  transferMode="Streamed"
  18:                  maxBufferSize="65536"
  19:                  maxReceivedMessageSize="5000000000"
  20:                  messageEncoding="Mtom"
  21:                  textEncoding="utf-8"
  22:                  receiveTimeout="04:00:00">
  23:           <security mode="Transport">
  24:             <transport clientCredentialType="None"></transport>
  25:           </security>
  26:         </binding>
  27:  
  28:       </basicHttpBinding>
  29:  
  30:     </bindings>
  31:  
  32:  
  33:     <behaviors>
  34:       <serviceBehaviors>
  35:         <behavior name="ServiceBehavior">
  36:           <serviceMetadata httpsGetEnabled="true"/>
  37:           <serviceDebug includeExceptionDetailInFaults="true"/>
  38:         </behavior>
  39:       </serviceBehaviors>
  40:     </behaviors>
  41:   </system.serviceModel>

 

On the client side, I am setting the config in code. 

 

   1: BasicHttpBinding binding = new BasicHttpBinding();
   2: binding.AllowCookies = false;
   3: binding.ReceiveTimeout = new TimeSpan(0, 10, 0);
   4: binding.SendTimeout = new TimeSpan(0, 5, 0);
   5: binding.OpenTimeout = new TimeSpan(0, 5, 0);
   6: binding.BypassProxyOnLocal = false;
   7: binding.MessageEncoding = WSMessageEncoding.Mtom;
   8: binding.TextEncoding = Encoding.UTF8;
   9: binding.TransferMode = TransferMode.Streamed;
  10:  
  11: //buffer size
  12: binding.MaxBufferSize = 65536;
  13: binding.MaxBufferPoolSize = 534288;
  14: binding.HostNameComparisonMode = HostNameComparisonMode.StrongWildcard;
  15:  
  16: //quotas
  17: binding.ReaderQuotas.MaxDepth = 32;
  18: binding.ReaderQuotas.MaxStringContentLength = 8192;
  19: binding.ReaderQuotas.MaxArrayLength = 16384;
  20: binding.ReaderQuotas.MaxBytesPerRead = 4096;
  21: binding.ReaderQuotas.MaxNameTableCharCount = 16384;
  22:  
  23: binding.Security.Mode = BasicHttpSecurityMode.Transport;
  24: binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.None;
  25: binding.Security.Transport.ProxyCredentialType = HttpProxyCredentialType.None;
  26: binding.Security.Message.ClientCredentialType = BasicHttpMessageCredentialType.UserName;
  27:  
  28: return binding;

 

 

Hopefully that will help anyone that is working to get SSL set up with WCF.

Tags:

Butchering Day 2010

by Lynn Roth 31. December 2010 14:24

Kate and I spent the morning butchering at Mike and Linda's.  Kate had a good time getting up early and helping with the hog butchering.  She was a good helper and was mixing sausage meat, taping and labeling packages, and taste testing the sausage.  She said she wants to do it again next year.

 

5D-20101231-2871_el

5D-20101231-2872_el

5D-20101231-2880_el

5D-20101231-2875_el

5D-20101231-2882_el

5D-20101231-2883_el

5D-20101231-2868

5D-20101231-2869

5D-20101231-2884_el

Tags:

Kate’s Christmas Program

by Lynn Roth 3. December 2010 07:48

Pettisville had their Elementary Christmas program this evening.  Kate was a little nervous but she did well.  Here is her singing the Penguin Polka and Away in a Manger.

5D-20101202-2557-ec

5D-20101202-2547-e

 

 

Christmas Program 2010 from Lynn Roth on Vimeo.

Tags:

About me

Tag cloud

    Disclaimer
    The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

    © Copyright 2012 Penguin Musings