I am writing a client program in VB6 which will interface to a server over HTTP. The company who runs the server provided me with a certificate file called SomeCertificate.p12.
My program is running on Windows XP. This is the operating system the customer is using.
I am trying to find how to use this certificate when sending requests to the server.
Here is what I have done so far:
- Copied the certificate file to my test computer.
- Using Internet Explorer V8, I did "Tools|Internet Options|Content|Certificates|Trusted Root Authorities" and imported the certificate.
- Installed the winhttpcertcfg tool.
Ran the following from command prompt:
"winhttpcertcfg -i SomeCertificate.p12 -c LOCAL_MACHINE\My -a COMPUTERNAME\USERNAME -p PasswordFromServerCompany"
the output was something like this. I replaced the different tokens with dummy strings:
Imported certificate:
CN=string1
OU=string2
O=string3
L=string4
C=string5
Private key access has already been granted for account: COMPUTERNAME\USERNAME
My VB6 code looks something like this:
Private WithEvents m_ServerObj As WinHttpRequest Set m_ServerObj = New WinHttpRequest m_ServerObj.Open "GET", "https://serveraddress"
Call m_ServerObj.SetClientCertificate("LOCAL_MACHINE\Personal\SomeCertificate")
m_ServerObj.Send TextToSend
The Send call causes an exception: "A certificate is required to complete client authentication"
I tried different strings in the SetClientCertificate call but I keep getting the same error.
I'd appreciate any help and tips. What am i doing wrong? Is my code wrong? Did I use winhttpcertcfg incorrectly?
thank you.