![](/img/trans.png)
[英]SOAP Error: The request was aborted: Could not create SSL/TLS secure channel
[英]IIS Blocking My Request. Could not create SSL/TLS secure channel
當我向某個 URL 發出第三方請求時,IIS 給我錯誤:
請求被中止:無法創建 SSL/TLS 安全通道。
但是我可以從控制台應用程序和郵遞員向相同的 URL 發出請求。
Dim certificates As X509Certificate2 = New X509Certificate2()
Dim uriPath As String = "D:\CertificateFolder\MyCert.cer"
Dim localPath As String = New Uri(uriPath).LocalPath
certificates.Import(localPath)
Dim sResult As String = ""
Dim activeProtocol As SecurityProtocolType =
ServicePointManager.SecurityProtocol
Try
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 Or
SecurityProtocolType.Tls11
Dim oRequest As HttpWebRequest =
WebRequest.Create("https://test.com/router.dll")
oRequest.KeepAlive = False
oRequest.Method = "POST"
oRequest.ContentType = "text/xml"
Dim Test As String = "some xml"
Dim bytes As Byte() = Text.Encoding.UTF8.GetBytes(Test)
oRequest.ContentLength = bytes.Length
oRequest.ClientCertificates = New X509CertificateCollection({certificates})
Dim oWriter As StreamWriter
Try
Dim streamToSend As Stream = oRequest.GetRequestStream()
oWriter = New StreamWriter(oRequest.GetRequestStream())
streamToSend.Write(bytes, 0, bytes.Length)
streamToSend.Close()
Catch up As Exception
Return
Finally
End Try
Dim oResponse As HttpWebResponse = oRequest.GetResponse()
Dim oReader As New StreamReader(oResponse.GetResponseStream())
sResult = oReader.ReadToEnd
oReader.Close()
Catch
' do nothing for now
Finally
ServicePointManager.SecurityProtocol = activeProtocol
End Try
注意* URL 中的方法不是文件。 方法名稱與方法名稱一樣具有 .dll。 我正在使用 .net 框架 4.5
您是否有權訪問服務器管理? 您可以先嘗試在不提供客戶端證書的情況下進行連接嗎? 從您的代碼中刪除相應的部分,並在 IIS 管理控制台中關閉客戶端證書要求。
如果錯誤仍然存在,請找出客戶端支持哪種密碼以及服務器支持哪種密碼。 如果他們沒有太多類似的錯誤就會發生。 要檢查客戶端,請重寫您的代碼以連接到以下站點:“ https://howsmyssl.com/a/check ” 如果您連接的服務器是公共的(互聯網可見),您可以使用以下站點進行檢查其支持的密碼套裝: https : //www.ssllabs.com/ssltest/
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.