繁体   English   中英

通过SSL + X.509的Web服务返回SSL / TLS错误

[英]Web Service over SSL + X.509 returns SSL/TLS error

我已经在Visual Studio 2013中编写了一个asmx Web服务。WS正在使用HTTPS和X.509进行身份验证连接到提供程序。

我尝试使用“ basicHttpBinding”和“ basicHttpsBinding”(Web.config)进行连接,但始终收到以下错误。

错误:System.ServiceModel.Security.SecurityNegotiationException:无法使用授权“ www.providers-site.se”为SSL / TLS建立安全通道。 ---> System.Net.WebException:请求已中止:无法创建SSL / TLS安全通道。 在System.Net.HttpWebRequest.GetResponse()在...

我为X.509创建了一个行为,并为端点创建了一个绑定,请参见下文。 我究竟做错了什么? 我可以从使用wsHttpBinding中受益吗?

<behaviors>
   <endpointBehaviors>
     <behavior name="CertBehaviour">
       <clientCredentials>
         <clientCertificate findValue="MyCertCN" storeLocation="LocalMachine"
                            storeName="My" x509FindType="FindBySubjectName" />
          <serviceCertificate>
          <authentication certificateValidationMode="PeerTrust" />
          </serviceCertificate>
       </clientCredentials>
     </behavior>
   </endpointBehaviors>
 </behaviors>

...

<basicHttpsBinding>
   <binding name="mySoapBinding">
     <security mode="Transport">
       <transport clientCredentialType="Certificate" />
        <message clientCredentialType="Certificate" />
     </security>
   </binding>
  </basicHttpsBinding>

...

<client>
  <endpoint address="https://www.providers-site.se/na/na_epersondata/services/personpostXML"
                behaviorConfiguration="CertBehaviour" binding="basicHttpsBinding"
                bindingConfiguration="mySoapBinding" contract="webservice.NaPersonPostXMLWS"
                name="personpostXML" />
</client>

我确实追踪了。 感谢Mike Cheel! 请参阅此处的跟踪。

此跟踪是否表示远程主机(提供者)不接受证书? (第67-71行)(由于在证书认证之后启动了“ AUTHENTICATE_REQUEST NOTIFICATION_CONTINUE”和“ AnonymousAuthenticationModule”。)

CertificateMappingAuthenticationModule NOTIFY_MODULE_START RequestNotifications AUTHENTICATE_REQUEST
AUTH_START Authentication MapCliCert
AUTH_END Authentication
CertificateMappingAuthenticationModule NOTIFY_MODULE_END RequestNotifications AUTHENTICATE_REQUEST NOTIFICATION_CONTINUE  
AnonymousAuthenticationModule NOTIFY_MODULE_START RequestNotifications  AUTHENTICATE_REQUEST

确保您的asmx计算机的受信任的根存储中具有提供商站点服务的证书链。 您可以通过在浏览器中输入ur来查找:

https://www.providers-site.se/na/na_epersondata/services/personpostXML

并查看其证书链。 浏览器还会显示警告。

暂时解决证书错误的另一种方法是尝试以下操作:

ServicePointManager.ServerCertificateValidationCallback = (sender, certificate, chain, sslPolicyErrors) => 
    {
     // put a breakpoint here
     var tempSslErrors = sslPolicyErrors;
     return  true;
    }

如果您查看sslPolicyErrorsit可能会给出一些指示。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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