• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 562
  • Last Modified:

HTTPS POST USING MSXML

I am trying to do an HTTP Post of a text file to a SSL server using WinHTTP. I keep getting the error "a security error occurred". I get the same error using Msxml2.ServerXMLHTTP.6.0 as well. The web srvice I am posting to provided me certificates and I installed them into the LOCAL MACHINE\Personal store. Here is the code I am using:


Public Function SendReceiveHTTP(pstrMsgType, pstrXMLReqMsg)
	Dim lobjXMLHTTPObj
	Dim lstrACKMessage
	Dim lstrURL
	Dim lintNoOfURLs
	Dim lstrINIFile
	Dim lintICtr
	Dim lintURLRetryCnt
	Dim lintURLRetryTimeGap
	Dim lstrREQMessage
	Dim gintJCtr
    Dim id
    Dim pwd
	
	Set lobjXMLHTTPObj = CreateObject("WinHttp.WinHttpRequest.5.1")
	


	lstrREQMessage = pstrXMLReqMsg
	
	
    lstrURL = ReadIni("Settings.ini", "HTTPPATH", "Path")

	LogEvent "OPENING CONNECTION AT :" & lstrURL

    id =  ReadIni("Settings.ini", "USER", "ID")
    pwd = ReadIni("Settings.ini", "USER", "PWD")
			
	
    lobjXMLHTTPObj.Open "POST", lstrURL, False
	    

    LogEvent("Logging without credentials")
			
	LogEvent "PREPARED TO SEND MESSAGE " & pstrMsgType	
    
    lobjXMLHTTPObj.setRequestHeader "Content-Type", "application/x-wmflatfile"


	
	   

	lobjXMLHTTPObj.Send lstrREQMessage
			
	LogEvent "SENT MESSAGE WITH :" & RetHttpMessage(lobjXMLHTTPObj.status)
		
	SendReceiveHTTP = lobjXMLHTTPObj.responseText     		
	
	If lobjXMLHTTPObj.status = 200 Then
		LogEvent "SendReceiveHTTP CONNECTION ATTEMPT  SUCCESSFULL"		
	else 
	LogEvent "SendReceiveHTTP CONNECTION ATTEMPT  FAILED"
    End If
		 	
	
	If lobjXMLHTTPObj.status <> 200 Then
		Logevent VbCrLf & "*************************** ABORMAL PROGRAM TERMINATION ************************************ " & VbCrLf & _
		 "HTTP ERROR NO : " & lobjXMLHTTPObj.status  & VbCrLf & _
		 "HTTP ERROR DESC : " & RetHttpMessage(lobjXMLHTTPObj.status) & VbCrLf & _
		 "HTTP ERROR URL : " & lstrURL & VbCrLf & _				
		 "*************************** ABORMAL PROGRAM TERMINATION ************************************ "  & VbCrLf
		WScript.Quit(0)		
	End If
	Set lobjXMLHTTPObj = Nothing
	
End Function

Open in new window

0
Rhayes28054
Asked:
Rhayes28054
1 Solution
 
shalomcCTOCommented:
You have to explicitly specify which user certificate to use.

This article shows how to use WinHttpSetOption to specify a certificate from the cert store.

http://msdn.microsoft.com/en-us/library/aa384076(v=vs.85).aspx

0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

On-Demand: Securing Your Wi-Fi for Summer Travel

Traveling this summer?Check out our on-demand webinar to learn about the importance of Wi-Fi security and 3 easy measures you can start taking immediately to protect your private data while using public Wi-Fi. Follow us today to learn more!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now