开发者

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

开发者 https://www.devze.com 2023-02-27 01:12 出处:网络
I have a plain WCF service hosted in IIS Express in Visual Studio 2010. IIS Express is configured to use 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" receiv开发者_运维百科eTimeout="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.

0

精彩评论

暂无评论...
验证码 换一张
取 消