gpt4 book ai didi

vb.net - IIS 阻止我的请求。无法创建 SSL/TLS 安全通道

转载 作者:太空宇宙 更新时间:2023-11-03 14:28:41 24 4
gpt4 key购买 nike

当我向某个 URL 发出第三方请求时,IIS 给我错误:

The request was aborted: Could not create SSL/TLS secure channel.

但是我可以从控制台应用程序和 Postman 向相同的 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 Framework 4.5

最佳答案

您有权访问服务器管理吗?您可以先尝试连接而不提供客户端证书吗?从您的代码中删除相应的部分,并在 IIS 管理控制台中关闭客户端证书要求。

如果错误仍然存​​在,请找出客户端支持的密码和服务器支持的密码。如果他们不多,就会发生与您类似的错误。要检查客户端,请重写代码以连接到以下站点:“https://howsmyssl.com/a/check”如果您连接的服务器是公共(public)服务器(互联网可见),您可以使用以下站点检查其支持的密码套装: https://www.ssllabs.com/ssltest/

关于vb.net - IIS 阻止我的请求。无法创建 SSL/TLS 安全通道,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54668147/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com