简体   繁体   中英

Trouble adding service reference to WCF service hosted in IIS Express with SSL

I have a plain WCF service hosted in IIS Express in Visual Studio 2010. IIS Express is configured to use SSL.

Before switching to SSL, I had no problems, but now I cannot update are add a service reference to my WCF Service (which is just a normal IIS hosted svc file).

When I use the WCFTestClient, I get a little more useful error:

Error: Cannot obtain Metadata from https://localhost:44302/Services/TrueChecksService.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:44302/Services/TrueChecksService.svc Metadata contains a reference that cannot be resolved: 'https://localhost:44302/Services/TrueChecksService.svc'. Could not establish trust relationship for the SSL/TLS secure channel with authority 'localhost:44302'. 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:44302/Services/TrueChecksService.svc There was an error downloading 'https://localhost:44302/Services/TrueChecksService.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.

Here's my config at the moment:

<system.serviceModel>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
<bindings>
  <basicHttpBinding>
    <binding name="MyBasicHttpBindingConfig" receiveTimeout="00:15:00"
      sendTimeout="00:15:00" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647">
      <security mode="Transport" />
    </binding>
  </basicHttpBinding>    
</bindings>
<services>
  <service name="TrueChecksService" behaviorConfiguration="TrueChecksServiceBehavior">
    <endpoint binding="basicHttpBinding" bindingConfiguration="MyBasicHttpBindingConfig"
      name="TrueChecksServiceEndpoint" contract="TrueChecksAdminSL.Web.Services.ITrueChecksService" />
    <endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange" />
  </service>
</services>
<behaviors>
  <serviceBehaviors>
    <behavior name="TrueChecksServiceBehavior">
      <useRequestHeadersForMetadataAddress>
        <defaultPorts>
          <add port="44302" scheme="https"/>
        </defaultPorts>
      </useRequestHeadersForMetadataAddress>
      <serviceMetadata httpGetEnabled="false" httpsGetEnabled="true"/>
      <serviceDebug includeExceptionDetailInFaults="false"/>
    </behavior>
  </serviceBehaviors>
</behaviors>

Do I need to write a custom certificate validator, since IIS Express generates a self-signed certificate? I was trying to solve without doing that because when I deploy to IIS, the site will be configured with a certificate issued by a certificate authority.

Thanks for any help.

Browse the URL from IE. You would see the warning that there is a problem with the website's security certificate. Follow the steps in what-do-i-need-to-do-to-get-ie8-to-accept-a-self-signed-certificate . When that is successful and you can get to the site without getting that warning in IE, the WCFClient would also be able to get to it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM