Creating a WCF Client Part 1: svcutil.exe, self-signed certs and Fiddler


Last week I had the opportunity to create my first WCF (Windows Communication Foundation) client. Unfortunately, svcutil wasn't cooperating...

 

Error message: 

WS-Metadata Exchange Error
    URI: https://someURL/NewsFeed.svc?wsdl
 
    Metadata contains a reference that cannot be resolved: 'https://someURL/NewsFeed.svc?wsdl.
    Could not establish trust relationship for the SSL/TLS secure channel with authority 'someURL.
    The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure channel.
    The remote certificate is invalid according to the validation procedure.

HTTP GET Error
    URI: https://someURL/NewsFeed.svc?wsdl
    There was an error downloading 'https://someURL/NewsFeed.svc?wsdl'.
    The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure channel.
    The remote certificate is invalid according to the validation procedure.

 

Notes:

 

Hmm… It looks like svcutil does NOT like self-signed certificates!

To get around this problem I ended up using the following steps: 

  1. Download, Install & run Fiddler
  2. Navigate to Tools -> Fiddler Options…
  3. Click on the HTTPS tab
  4. Ensure that the option to Decrypt HTTPS traffic is checked
  5. Accept the prompt to install the Fiddler certificate (windows will ask)
  6. Restart Fiddler
  7. Run svcutil against your WSDL URL:
    svcutil.exe https://someURL/NewsFeed.svc?wsdl

Unless some other issue comes up, svcutil should auto-generate the class and .config file you need to create your WCF client app

In Part 2 I discuss how to take the class and .config file to create a simple WCF client