|
-
May 16th, 2011, 09:32 AM
#1
Thread Starter
Addicted Member
[RESOLVED] WinHttpRequest - Certificate
Hello All,
I am getting a "Certificate is required to complete client authentication" when sending a client certificate through WinHttpRequest. I am setting the credentials and opening the website.
Any ideas?
Code:
Dim TestMe As New WinHttpRequest
lstrBaseURL = "https://test.testplace.com:1234"
TestMe.open "GET", lstrBaseURL, False
TestMe.SetClientCertificate ("LOCAL_MACHINE\Personal\Name of Cert Here")
TestMe.SetCredentials "12345678", "PSWD", HTTPREQUEST_SETCREDENTIALS_FOR_SERVER
TestMe.send (mstrCompleteSegment)
TestMe.waitForResponse
Dave
-
May 16th, 2011, 10:13 AM
#2
Re: WinHttpRequest - Certificate
No idea why you are putting parentheses around your arguments, since it can prduce results you proboably don't expect such as passing by value. That's probably not your problem though, and just makes your code look ugly here.
Is the intended cert really in HKLM and not HKCU?
-
May 16th, 2011, 10:21 AM
#3
Thread Starter
Addicted Member
Re: WinHttpRequest - Certificate
Okay...I took out the () and changed the TestMe.SetClientCertificate ("LOCAL_MACHINE\Personal\Name of Cert Here") to
Code:
TestMe.SetClientCertificate ("CURRENT_USER\\Personal\\Name of Cert Here")
Still getting the same issue.
-
May 16th, 2011, 10:31 AM
#4
Re: WinHttpRequest - Certificate
Hmm, I still see the parens there... but as I said it won't make a difference.
Why on Earth would you be escaping \'s in a VB6 String though??? You're just copy/pasting aren't you? I think you found a JScript example.
Do you really have that certificate in your certificate store? Can you see it in the registry?
-
May 16th, 2011, 10:41 AM
#5
Thread Starter
Addicted Member
Re: WinHttpRequest - Certificate
Okay, I did strike the parentheses.
I am not seeing this in the registry. What would it be under?
-
May 16th, 2011, 10:44 AM
#6
Re: WinHttpRequest - Certificate
This shows where the registry entries can be found: System Store Locations.
Also be sure you have that string right, it is case-sensitive.
-
May 16th, 2011, 11:20 AM
#7
Thread Starter
Addicted Member
Re: WinHttpRequest - Certificate
Thanks - I will look into that.
Thank you for your help. Sounds like you pointed me into the right direction. Much appreciated.
(I'll set the post to resolve once I figure out this is it)
-
May 16th, 2011, 12:22 PM
#8
Re: WinHttpRequest - Certificate
-
May 16th, 2011, 03:04 PM
#9
Thread Starter
Addicted Member
Re: WinHttpRequest - Certificate
Still working on this one. I cannot find the cert in the regedit for the life of me.
-
Nov 19th, 2021, 05:27 AM
#10
Re: [RESOLVED] WinHttpRequest - Certificate
For the poor souls who search the interwebs for the correct syntax to SetCredentials it's
.SetClientCertificate "CURRENT_USER\MY\Name of Cert Here"
To access certificates Personal store you have to use MY for the name of the store. The WinHTTP documentation misleadingly mentions CURRENT_USER\Personal\Xxx in most of its samples but this will actually look up for certificates in a *custom* certificate store named "Personal" so technically this is not incorrect selection string but the sample is not leading to expected results and only leads to numerous user questions and failures like the one above.
Also, to access certificates in CURRENT_USER\MY i.e. user's Personal certificate store you don't have to use any prefix, just use "Name of Cert Here" as the prefix CURRENT_USER\MY is the default certificate store WinHTTP uses when no store is specified in the selection string.
cheers,
</wqw>
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|