在 https 中调用 WebService
Call WebService in https
我创建了一个 webService 来生成 pdf 文件。在 VisualStudio 2012 的调试模式下。没关系。我可以从其他 IntranetSite 调用它。
我试着把它放在我的测试服务器上。但是我需要添加 https 而不是 http。
我发现this
我试着这样改编我的 web.config
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="GenerationCourriersSoap" >
<security mode="Transport">
<transport clientCredentialType="None" proxyCredentialType="None" realm="" />
<message clientCredentialType="Certificate" algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="secureBehaviours">
<serviceMetadata httpsGetEnabled="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
<client>
<endpoint address="https://localhost:52999/GenerationCourrier.asmx"
binding="basicHttpBinding" bindingConfiguration="GenerationCourriersSoap"
contract="WSCourrier.GenerationCourriersSoap" name="GenerationCourriersSoap" />
</client>
</system.serviceModel>
但是我有消息
Unable to establish a trust for the secure channel SSL / TLS with authority 'localhost: 52999'.
我直接使用了IIS建立的自动证书。
我验证,此证书位于我的根目录和安全文件夹中
有人有想法吗?
终于找到这个enter link description here
好像还不错。现在我可以访问网络服务了。
想法是强制验证所有证书。就是这样的考试时间
Imports System
Imports System.Net
Imports System.Security.Cryptography.X509Certificates
Public Class clsSSL
Public Function AcceptAllCertifications(ByVal sender As Object, ByVal certification As System.Security.Cryptography.X509Certificates.X509Certificate, ByVal chain As System.Security.Cryptography.X509Certificates.X509Chain, ByVal sslPolicyErrors As System.Net.Security.SslPolicyErrors) As Boolean
Return True
End Function
End Class
并在调用 WebService 函数之前调用函数
ServicePointManager.ServerCertificateValidationCallback = AddressOf AcceptAllCertifications
我创建了一个 webService 来生成 pdf 文件。在 VisualStudio 2012 的调试模式下。没关系。我可以从其他 IntranetSite 调用它。
我试着把它放在我的测试服务器上。但是我需要添加 https 而不是 http。
我发现this 我试着这样改编我的 web.config
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="GenerationCourriersSoap" >
<security mode="Transport">
<transport clientCredentialType="None" proxyCredentialType="None" realm="" />
<message clientCredentialType="Certificate" algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="secureBehaviours">
<serviceMetadata httpsGetEnabled="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
<client>
<endpoint address="https://localhost:52999/GenerationCourrier.asmx"
binding="basicHttpBinding" bindingConfiguration="GenerationCourriersSoap"
contract="WSCourrier.GenerationCourriersSoap" name="GenerationCourriersSoap" />
</client>
</system.serviceModel>
但是我有消息
Unable to establish a trust for the secure channel SSL / TLS with authority 'localhost: 52999'.
我直接使用了IIS建立的自动证书。 我验证,此证书位于我的根目录和安全文件夹中 有人有想法吗?
终于找到这个enter link description here
好像还不错。现在我可以访问网络服务了。
想法是强制验证所有证书。就是这样的考试时间
Imports System
Imports System.Net
Imports System.Security.Cryptography.X509Certificates
Public Class clsSSL
Public Function AcceptAllCertifications(ByVal sender As Object, ByVal certification As System.Security.Cryptography.X509Certificates.X509Certificate, ByVal chain As System.Security.Cryptography.X509Certificates.X509Chain, ByVal sslPolicyErrors As System.Net.Security.SslPolicyErrors) As Boolean
Return True
End Function
End Class
并在调用 WebService 函数之前调用函数
ServicePointManager.ServerCertificateValidationCallback = AddressOf AcceptAllCertifications