【问题标题】:Https certificate error, WCF service on IISHTTPS 证书错误,IIS 上的 WCF 服务
【发布时间】:2012-12-11 20:47:20
【问题描述】:

我想组织客户端和 WCF 服务之间的安全连接。客户必须确信它可以信任该服务。

我为本地计算机上的受信任根和个人存储创建了两个证书。我可以在证书插件中看到正确的证书路径。 证书公用名是 localhost。

我已经在 IIS 上添加了 https 的绑定。

我有以下配置的服务

行为

    <behavior name="AgencyTrustedServiceBehavior">
      <dataContractSerializer maxItemsInObjectGraph="10000000" />
      <serviceMetadata httpsGetEnabled="true" policyVersion="Policy15" />
      <serviceDebug includeExceptionDetailInFaults="true" />

      <serviceCredentials>
        <clientCertificate>
          <authentication certificateValidationMode="None"  />
        </clientCertificate>

        <serviceCertificate findValue="localhost" storeLocation="LocalMachine" storeName="My" x509FindType="FindBySubjectName" />

      </serviceCredentials>
    </behavior>

绑定

  <wsHttpBinding>
    <binding name="InternetServiceBinding" closeTimeout="00:10:00"
          openTimeout="00:10:00" sendTimeout="00:10:00" bypassProxyOnLocal="true"
          maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647"
          messageEncoding="Mtom">
      <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
        maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
      <security mode="Transport">
        <transport clientCredentialType="None">
          <extendedProtectionPolicy policyEnforcement="Never" />
        </transport>
      </security>
    </binding>
  </wsHttpBinding>

端点

  <service behaviorConfiguration="AgencyTrustedServiceBehavior" name="Megatec.MasterTourService.AuthService">
    <endpoint address="Anonymous" 
              binding="wsHttpBinding" 
              bindingConfiguration="InternetServiceBinding" 
              name="Megatec.MasterTourService.Contracts.IAuthServiceAnonymous" 
              contract="Megatec.MasterTourService.Contracts.IAuthService">
    </endpoint>
  </service>

但是,当我尝试使用 WCFTestClient 访问服务时,它会抛出以下异常

There was no endpoint listening at http://localhost/IISTest/AuthService.svc that could accept the message. This is often caused by an incorrect address or SOAP action. See InnerException, if present, for more details.    The remote server returned an error: (404) Not Found.

HTTP GET Error    URI: http://localhost/IISTest/AuthService.svc    The document at the url http://localhost/IISTest/AuthService.svc was not recognized as a known document type.The error message from each known type may help you fix the problem:
- Report from 'XML Schema' is 'The document format is not recognized (the content type is 'text/html; charset=UTF-8').'.
- Report from 'DISCO Document' is 'There was an error downloading 'https://dev4-10.megatec.ru/IISTest/AuthService.svc?disco'.'.  
- 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.
- Report from 'http://localhost/IISTest/AuthService.svc' is 'The document format is not recognized (the content type is 'text/html; charset=UTF-8').'.
- Report from 'WSDL Document' is 'The document format is not recognized (the content type is 'text/html; charset=UTF-8').'.

怎么了?

【问题讨论】:

  • 对于初学者,您不应该使用 https 吗?
  • 我使用 https。我为 IIS 添加了 https 绑定(使用此证书),我尝试访问 localhost/IISTest/AuthService.svc 地址

标签: wcf web-services iis https x509certificate


【解决方案1】:

客户端点击的网址是:

“http://localhost/IISTest/AuthService”

应该是

“https://localhost/IISTest/AuthService”

【讨论】:

猜你喜欢
  • 2011-03-18
  • 1970-01-01
  • 2023-03-23
  • 2013-10-29
  • 2012-08-06
  • 1970-01-01
  • 2014-01-08
  • 2017-11-02
  • 1970-01-01
相关资源
最近更新 更多