在VB6中使用MSXML2.ServerXMLHTTP.6.0的RPC
我正在与之通信的服务器正在使用SSL槽端口40052和a 自签名CA,我希望在发布之前我已经尝试使它工作了大约2天 有人可以提供帮助。
我的问题是当我调用方法发送
时如果未忽略ssl错误,则表示无效的证书颁发机构
如果忽略ssl错误,则表示服务器返回了无效或未记录的响应
Dim strXml As String
Dim xmlLength As Integer
strXml = "<?xml version=""1.0""?><methodCall> " & _
"<methodName>somemethod</methodName> " & _
"<params> " & _
"<param><value><string>en</string></value></param>" & _
"<param><value><string>something</string></value></param>" & _
"<param><value><string>00000</string></value></param>" & _
"<param><value><string>000000000000000000000</string></value></param>" & _
"</params>" & _
"</methodCall>"
xmlLength = Len(strXml)
' object to communicate with
Set xmlHttp = CreateObject("MSXML2.ServerXMLHTTP.6.0")
'since the server i am communicating with is using a self signed certificate authority
' I have to ignore all ssl errors.
xmlHttp.setOption 2, 13056
' I set the friendlyname of my certificate just in case i have tried with and without
xmlHttp.setOption 3, "myrealfriendlynameofcrt"
' I open the connection with the server.
' the server is NOT USING 443 for ssl it's using 50042
xmlHttp.Open "POST", "https://hostname.com:50042", False
' I specify my content type
xmlHttp.SetRequestHeader "Content-Type", "text/xml"
' I specify my content length (I did try with this line and without)
xmlHttp.SetRequestHeader "Content-Length", xmlLength
' I send my request ( MY ERROR OCCURS HERE )
' IF SSL ERRORS NOT IGNORE IT SAYS INVALID CERTIFICATE AUTHORITY
' IF SSL ERRORS IGNORED IT SAYS THE SERVER RETURNED AN INVALID OR UNRECOGNIZED RESPONSE
xmlHttp.send strXml
If xmlHttp.Status >= 400 And xmlHttp.Status <= 599 Then
Debug.Print "Error occured : " & xmlHttp.Status & " - " & xmlHttp.StatusText
Else
Debug.Print xmlHttp.ResponseText
End If
Set xmlHttp = Nothing