views:

509

answers:

3

I have a WCF web service running in IIS 7 using a self-signed certificate (it's a proof of concept to make sure this is the route I want to go). It's required to use SSL.

Is it possible to use the WCF Test Client to debug this service without needing a non-self-signed certificate?

When I try I get this error:

Error: Cannot obtain Metadata from https:///Service1.svc If this is a Windows (R) Communication Foundation service to which you have access, please check that you have enabled metadata publishing at the specified address. For help enabling metadata publishing, please refer to the MSDN documentation at http://go.microsoft.com/fwlink/?LinkId=65455.WS-Metadata Exchange Error URI: https:///Service1.svc Metadata contains a reference that cannot be resolved: 'https:///Service1.svc'. Could not establish trust relationship for the SSL/TLS secure channel with authority ''. 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:///Service1.svc There was an error downloading 'https:///Service1.svc'. 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.

EDIT: This question is specifically about using the WCF Test Client to test a web service already secured via SSL using a self-signed certificate. The server is already set up to accept any certificate provided, it's the WCF Test Client I don't see a way to do this for.

A: 

You can supply your own method to validate the certificate.

Try this:

ServicePointManager.ServerCertificateValidationCallback +=
            new System.Net.Security.RemoteCertificateValidationCallback(EasyCertCheck);

The call back:

bool EasyCertCheck(object sender, X509Certificate cert,
        X509Chain chain, System.Net.Security.SslPolicyErrors error)
{
    return true;
}
rgunawan
I do not see any way to add this code to the WCF Test Client (code which I do not control). I have already added this call to my own code (server side).
Lawrence Johnston
A: 

Check this code sample: Securing WCF (Windows Communication Foundation) transport wit SSL

EDIT: Client Config Settings:

I have a behaviour in my client config to disable certificate validation for testing (although i'm using a service certificate with message security rather than SSL), I'm not sure if you can modify the client config file but I think the principal should be the same. You could look into those config settings.

<behaviors>
  <endpointBehaviors>
    <behavior name="DisableServiceCertificateValidation">
      <clientCredentials>
        <serviceCertificate>
          <authentication certificateValidationMode="None"
                          revocationMode="NoCheck" />
        </serviceCertificate>
      </clientCredentials>
    </behavior>
  </endpointBehaviors>
</behaviors>

Have you tried modifying the client config with something like the above? There's a section describing Editing Client Configuration on this MSDN Link.

Tanner
I do not see any way to add this code to the WCF Test Client (code which I do not control). I have already added this call to my own code (server side).
Lawrence Johnston
Thanks for the negative... but you didn't specify all of that info when you posted originally.
Tanner
Yes, I did. Quote: "Is it possible to use the WCF Test Client to debug this service without needing a non-self-signed certificate?" and the title "Is it possible to force the WCF test client to accept a self-signed certificate?". These both very specifically state "The WCF Test Client".
Lawrence Johnston
WCF test client is a pretty generic phrase, but I now know what you are referring to. You win!
Tanner
+1  A: 

Hi Lawrence, you should be able to do this if you replace the WCF Test Client with WCFStorm Lite Edition. It's free and is quite a bit more flexible than MS's test client... for example, it'll let you specify a user name & password if you're doing username authentication.

Warren