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:
- svcutil.exe
- Fiddler2
- Stack overflow article on svcutil and untrusted certificates
Hmm… It looks like svcutil does NOT like self-signed certificates!
To get around this problem I ended up using the following steps:
- Download, Install & run Fiddler
- Navigate to Tools -> Fiddler Options…
- Click on the HTTPS tab
- Ensure that the option to Decrypt HTTPS traffic is checked
- Accept the prompt to install the Fiddler certificate (windows will ask)
- Restart Fiddler
- 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