WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

OLE with MSIE
plus

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

OLE HTTPS Download with Client Certificate


Question:

I am using Winbatch to automate file downloads from https websites. The program works great until a site is reached requiring a certificate.

Manually through IE6 the process works, (only one certificate is installed and I have the trusted root certificate for the company installed). The website is also configured as a trusted site.

I have tried using the various options under the iHttpInit with respect to certificates to no avail. I still receive the WinInet 12044 error.

Example code:

tophandle=iBegin(0,"","")
connecthandle=iHostConnect(tophandle,sHost,@HTTPS,sUser,sPass)
datahandle=iHttpInit(connecthandle,"GET",URL,"",0) 

Any thoughts as to how I can assign an existing certificate to be used with the Winbatch?

Answer:

You can download pages from the winbatch site using winbatch and HTTP via OLE... HTTPS looks about the same and you can set the Client Cert in it...
;Example Code
;
;The following example shows how to select a client certificate to send with a request. 
;A certificate with the subject "My Middle-Tier Certificate" is chosen from the "Personal" 
;certificate store in the registry under 
;
;HKEY_LOCAL_MACHINE

;  is your certificate in the same place in the registry as below ??? ...

WinHttpReq = objectopen("WinHttp.WinHttpRequest.5")
WinHttpReq.SetCredentials("user", "password", "")
WinHttpReq.Open("GET", "https://www.fabrikam.com/", @false)
WinHttpReq.SetClientCertificate("LOCAL_MACHINE\Personal\My Middle-Tier Certificate") ;<---
WinHttpReq.Send()

message("Debug", WinHttpReq.ResponseText)

oh = fileopen("C:\Test\winbatch.html", "write")
filewrite(oh, WinHttpReq.ResponseText)
fileclose(oh)

message("Debug", "All Done")

exit

; actual VB Code...

;Dim HttpReq As Object
;
;    ' Instantiate the WinHTTPRequest ActiveX Object.
;    Set HttpReq = New WinHttpRequest
;    
;    ' Open an HTTP connection.
;    HttpReq.Open "GET", "https://www.fabrikam.com/", False
;    
;    'Select a client certificate.
;    HttpReq.SetClientCertificate "LOCAL_MACHINE\Personal\My Middle-Tier Certificate"
;
;    ' Send the HTTP Request.
;    HttpReq.Send

Article ID:   W16129
File Created: 2004:03:30:15:42:58
Last Updated: 2004:03:30:15:42:58