Saturday, March 24, 2012

WCF Hosted in IIS over SSL

I've got a Windows Communication Foundation service that I'm hosting in IIS 6 and running over SSL using a certificate that I created using selfssl. I'm able to view the .svc with no errors in IE but when I tried to add a service reference to it in Visual Studio I got the following error:

Error: Cannot obtain Metadata from https://localhost:777/AuthService.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://localhost:777/AuthService.svc

Metadata contains a reference that cannot be resolved: 'https://localhost:777/AuthService.svc'.

Could not establish trust relationship for the SSL/TLS secure channel with authority 'localhost:777'.

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://localhost:777/AuthService.svc

There was an error downloading 'https://localhost:777/AuthService.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.

I checked the article it referenced in the error message and I can't find anything I've got setup wrong. Thanks in advance for any help. Here's my config file:

<

system.serviceModel>

<

bindings>

<

wsHttpBinding>

<

bindingname="sslTest">

<

securitymode="Transport">

<

transportclientCredentialType="None"/>

</

security>

</

binding>

</

wsHttpBinding>

</

bindings>

<

services>

<

servicename="HEI.Auth.BL.AuthUtil"behaviorConfiguration="myServiceBehavior">

<

endpointaddress=""binding="wsHttpBinding"bindingConfiguration="sslTest"contract="HEI.Auth.BL.Interfaces.IAuthenticate" />

<

endpointcontract="IMetadataExchange"binding="mexHttpsBinding"address="mex"/>

<

host>

<

baseAddresses>

<

addbaseAddress="https://localhost:777/AuthService"/>

</

baseAddresses>

</

host>

</

service>

</

services>

<

behaviors>

<

serviceBehaviors>

<

behaviorname="myServiceBehavior">

<

serviceMetadatahttpsGetEnabled="true"httpsGetUrl=""/>

</

behavior>

</

serviceBehaviors>

</

behaviors>

</

system.serviceModel>Sorry if I missed something, but this doesn't appear to be related to ASP.NET AJAX. You might get better help on a WCF forum.
The reason I posted it here is because I did a search for wcf and this was about the only forum that had any posts for wcf. Anyway, it was a problem with my certificate. I created a certificate with selfssl but I didn't name it "localhost" so the certificate didn't match the site address. Once I made a new certificate with cn=localhost I was able to add the service reference in visual studio.

No comments:

Post a Comment