XML-RPC HTTPS POST USING MSXML2.ServerXMLHTTP.6.0 VB 6

dsylebee picture dsylebee · Nov 9, 2012 · Viewed 11k times · Source

RPC using MSXML2.ServerXMLHTTP.6.0 in VB6

the server I am communicating with is using SSL trough port 40052 and a self signed CA, I have tried to make it work for about 2 days now before posting, I hope someone can help.

My problem is when i call the method Send

If the ssl errors are not ignored it says invalid certificate authority

if the ssl errors are ignored it says the server returned an invalid or unrecongnized response

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

Answer