Results 1 to 10 of 10

Thread: [RESOLVED] WinHttpRequest - Certificate

  1. #1

    Thread Starter
    Addicted Member thedoc1's Avatar
    Join Date
    Jan 2002
    Location
    Scenic Tonawanda, NY
    Posts
    143

    Resolved [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
    Thanks

    Doc

  2. #2
    PowerPoster dilettante's Avatar
    Join Date
    Feb 2006
    Posts
    24,487

    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?

  3. #3

    Thread Starter
    Addicted Member thedoc1's Avatar
    Join Date
    Jan 2002
    Location
    Scenic Tonawanda, NY
    Posts
    143

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

    Doc

  4. #4
    PowerPoster dilettante's Avatar
    Join Date
    Feb 2006
    Posts
    24,487

    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?

  5. #5

    Thread Starter
    Addicted Member thedoc1's Avatar
    Join Date
    Jan 2002
    Location
    Scenic Tonawanda, NY
    Posts
    143

    Re: WinHttpRequest - Certificate

    Okay, I did strike the parentheses.

    I am not seeing this in the registry. What would it be under?
    Thanks

    Doc

  6. #6
    PowerPoster dilettante's Avatar
    Join Date
    Feb 2006
    Posts
    24,487

    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.

  7. #7

    Thread Starter
    Addicted Member thedoc1's Avatar
    Join Date
    Jan 2002
    Location
    Scenic Tonawanda, NY
    Posts
    143

    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)
    Thanks

    Doc

  8. #8
    PowerPoster dilettante's Avatar
    Join Date
    Feb 2006
    Posts
    24,487

    Re: WinHttpRequest - Certificate

    Good luck!

  9. #9

    Thread Starter
    Addicted Member thedoc1's Avatar
    Join Date
    Jan 2002
    Location
    Scenic Tonawanda, NY
    Posts
    143

    Re: WinHttpRequest - Certificate

    Still working on this one. I cannot find the cert in the regedit for the life of me.
    Thanks

    Doc

  10. #10
    PowerPoster wqweto's Avatar
    Join Date
    May 2011
    Location
    Sofia, Bulgaria
    Posts
    6,177

    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
  •  



Click Here to Expand Forum to Full Width