簡體   English   中英

在.net中訪問遠程服務時出錯

[英]Error while accessing Remote Service in .net

我們正在嘗試通過HTTPS從遠程系統訪問Java Web服務到我們的.net客戶端系統。我們面臨一個錯誤:

這可能是由於在HTTPS情況下未使用HTTP.SYS正確配置服務器證書。 這也可能是由於客戶端和服務器之間的安全綁定不匹配引起的

有趣的是,它可以在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;

}

dotnet框架可能與支持的TLS版本有關。 我所知道的,。 Net4.0與tls1.2不兼容,有關詳細信息,請參考以下問題。
System.Net.WebRequest支持哪些版本的SSL / TLS?
使用以下代碼段設置配置。

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

請隨時告訴我是否有什么可以幫助的。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM