简体   繁体   English

在.net中访问远程服务时出错

[英]Error while accessing Remote Service in .net

We are trying to access a java webservice through HTTPS from remote system in to our .net client system.we are facing an error: 我们正在尝试通过HTTPS从远程系统访问Java Web服务到我们的.net客户端系统。我们面临一个错误:

This could be due to the fact that the server certificate is not configured properly with HTTP.SYS in the HTTPS case. 这可能是由于在HTTPS情况下未使用HTTP.SYS正确配置服务器证书。 This could also be caused by a mismatch of the security binding between the client and the server 这也可能是由于客户端和服务器之间的安全绑定不匹配引起的

Interesting thing is it is working in SOAP UI,but only problem with visual studio.Why it is working in soap UI rather not in Visual studio2010 有趣的是,它可以在SOAP UI中工作,但仅是Visual Studio的问题。为什么它可以在肥皂UI中工作,而不是在Visual Studio2010中工作

protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            ServicePointManager.ServerCertificateValidationCallback += new System.Net.Security.RemoteCertificateValidationCallback(CertificationvAlidatefunction);
            mainclass.ClientCredentials.UserName.UserName = "testuser";
            mainclass.ClientCredentials.UserName.Password = "test123";


            response = mainclass.Testmethod(request);

        }
        catch (Exception ex)
        {
            Response.Write(ex.Message);
        }
    }
  private bool CertificationvAlidatefunction(object sender, System.Security.Cryptography.X509Certificates.X509Certificate certificate,
      System.Security.Cryptography.X509Certificates.X509Chain chain, SslPolicyErrors errors)
    {
        return true;

} }

It is possible that the dotnet framework is related to the version of TLS supported. dotnet框架可能与支持的TLS版本有关。 As far as I know,. 我所知道的,。 Net4.0 is not compatible with tls1.2,you could refer to the following question for details. Net4.0与tls1.2不兼容,有关详细信息,请参考以下问题。
Which versions of SSL/TLS does System.Net.WebRequest support? System.Net.WebRequest支持哪些版本的SSL / TLS?
Set up the configuration by using the following code snippets. 使用以下代码段设置配置。

 ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls11;
            ServiceReference2.Service1Client client = new ServiceReference2.Service1Client();
            client.ClientCredentials.ServiceCertificate.SslCertificateAuthentication =
 new X509ServiceCertificateAuthentication()
 {
     CertificateValidationMode = X509CertificateValidationMode.None,
     RevocationMode = X509RevocationMode.NoCheck
 };

Feel free to let me know If there is anything I can help with. 请随时告诉我是否有什么可以帮助的。

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

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