VB.Net HTTP请求

有一个VB的HTTP请求,一直能正常使用,但有一次服务器SSL证书更新后,突然就不能用,代码如下:
Private Function POST(ByVal URL$, ByVal data$)
Dim http
On Error Resume Next
http = CreateObject("WinHttp.WinHttpRequest.5.1")
With http
.Open("POST", URL, False)
.setRequestHeader("Accept-Language", "zh-CN")
.setRequestHeader("Cache-Control", "no-cache")
.setRequestHeader("User-Agent", "Mozilla/4.0")
.setRequestHeader("Connection", "Keep-Alive")
.setRequestHeader("Content-Length", data.Length)
.setRequestHeader("Content-Type", "application/x-www-form-urlencoded")
.Send(data)
.WaitForResponse()
POST = .getallresponseheaders
Dim request = http.responseText
End With
http = Nothing
End Function

日志显示错误
nginx SSL (SSL: error:14201044:SSL routines:tls_choose_sigalg: internal error)
关于此错误网上资料很少,原因不明,有一种说法是请求头中,ClientHello为空造成,但无法证实,因为证书更新前并无此错误
后来查到另一种方法解决了此问题,当然不能用原来的post方法了,新POST代码如下:
网上原代码
Sub ShopXML4http(url, inStr, outStr, method, xmlerror)
Dim objhttp
Set objhttp = Server.CreateObject ("MSXML2.ServerXMLHTTP.6.0")
objHttp.open method, url, false
If Method="POST" Then
objHttp.Send instr
Else
objHttp.Send
End if
outstr=objHttp.responseText
Set objhttp=nothing
End Sub

修改精简后的代码
Private Sub NPost(url, inStr)
Dim objhttp
objhttp = CreateObject("MSXML2.XMLHTTP.6.0")
objhttp.open("POST", url, True)
objhttp.Send()
objhttp = Nothing
End Sub

修改后的代码能正常发出请求并被服务器接受

两种请求方法主要区别是:
前一种用了WinHttp.WinHttpRequest.5.1
后一种用了MSXML2.XMLHTTP.6.0

滚动至顶部