0

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:

  1. Copied the certificate file to my test computer.
  2. Using Internet Explorer V8, I did "Tools|Internet Options|Content|Certificates|Trusted Root Authorities" and imported the certificate.
  3. Installed the winhttpcertcfg tool.
  4. 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

  1. 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.

yaronkl
  • 510
  • 2
  • 5
  • 18
  • The fact i am using VB6 right now should not matter. The program is using Windows winhttp.dll, a COM object. I could have used C++ and still have the same problem. – yaronkl Jul 25 '17 at 21:43

1 Answers1

0

The server company sent me a .PEM certificate to install. Once I did that, the problem was solved. Thank you.

yaronkl
  • 510
  • 2
  • 5
  • 18