locked
WinHttp RRS feed

  • Question

  • Hello:

    I need to send a request to a web server using https with client certificate within a script. I'm using WinHttp with Java Script. The client certificate is installed and all the priviliges are all right. From IE I can connect to the server without problem. In MSDN I have found an example of winhttp ussage but I think something is wrong with the sample. The script always return: "A certificate is required to complete client authentication". I have used the certifcates snap-in to see in where the certificate is installed, and all seems to be right. MSDN documentation says that if the certificate is the only one in a particular address of the certifcate store, you can use for the certificate's subject name a blank string or the name string; I have tried with both. Could someone please tell me if is there any mistake in the MSDN documentation about WinHttp or in my script?

    Many thanks.

    Certificates snap-in info: certificate appears in: Local machine/Personal/Certificates, and is the only one.

    JS code:

    // Load the WinHttpRequest object.
    var WinHttpReq = new ActiveXObject("WinHttp.WinHttpRequest.5.1");
       
    // Open an HTTP connection.
    WinHttpReq.Open("GET", "https://oneserver.com", false);
       
    // Select a client certificate.
    WinHttpReq.SetClientCertificate("LOCAL_MACHINE\\Personal\\");

    // Send the HTTP Request.
    WinHttpReq.Send();

    Thursday, March 1, 2007 4:41 PM

Answers

  • Hello:

    Finally I found the solution for this problem. I used the winhttpcertcfg.exe tool to register in the system the certificate. As it appears to be the registration of the certificate with Internet Explorer doesn't work with winhttp. A system registration is needed.

    I have now another question to the forum. I posted it in another thread.

    Thanks.

    Monday, March 5, 2007 12:07 PM