Right now in my project, I save the encoded X509 certificate at a location like
http://www.my-ca-web.com/clientcerts/your-cert.cer
, a user can simply click a link to that location on the web interface to download it.
And because .cer is a built-in file type of Windows, once a user double clicks that file,
Windows knows how to handle it, i.e., asks the user to import it to the browser IE.
However, I don't want to return the certificate to the client in such a shabby way. Instead I
want to put the encoded certificate in a session object. But then we have no way of utilizing
the .cer file extension.
So, here is the question:
If I store the encoded client certificate in a session object, in which case, we cannot make
use of the built-in .cer file type for Windows, how can we import the certificate to the IE
browser? I believe we need VBScript to do this, but I am very very dumb at VBScript.
Any sample code is highly appreciated. Thanks a lot.
'*************************************************************
' File: getimportcert.vbs (WSH for VBscript)
' Author: (c) M. Gallant 04/10/2003
'
' Network certificate download and import utility
' Installs certificate to "AddressBook" (Other) store.
' Displays certificate before adding to store.
' Handles base64 or binary DER certificates.
'
' Requires CAPICOM 2.0.0.1
' Requires WSH 5.6
'
' Michel Gallant Copyright 2003
'*************************************************************
Option Explicit
Const CAPICOM_CURRENT_USER_STORE = 2
Const CAPICOM_LOCAL_MACHINE_STORE = 1
Const CAPICOM_STORE_OPEN_READ_WRITE = 1
Const CAPICOM_MY_STORE = "CAPICOM_MY_STORE"
Const CAPICOM_OTHERS_STORE = "AddressBook"
Dim oHttp, oUtils, oCert, body, certStr, certURL, oMystore
set oHTTP = CreateObject("Microsoft.XMLHTTP")
set oUtils = CreateObject("CAPICOM.Utilities")
set oCert = CreateObject("CAPICOM.Certificate")
certURL = "<a valid url to a cert>"
oHTTP.open "GET", certURL, False
oHTTP.send
body = oHTTP.responseBody 'safearray (byte) contents
certStr = oUtils.ByteArrayToBinaryString(body)
oCert.Import(certStr)
oCert.Display()
'------- Now add to the MY store -----------
set oMystore = CreateObject("CAPICOM.Store")
oMystore.open CAPICOM_CURRENT_USER_STORE, CAPICOM_OTHERS_STORE, _
CAPICOM_STORE_OPEN_READ_WRITE
oMystore.add oCert
'---------------------------------------------
' Release all objects.
set oMystore = nothing
set oHTTP = nothing
set oUtils = nothing
set oCert = nothing
----------------- END VBS --------------------
<burki...@hotmail.com> wrote in message news:b8aiqg$4pu$1...@news.state.mn.us...
--
This posting is provided "AS IS" with no warranties and confers no rights.
Use of any included samples is subject to the terms specified at
http://www.microsoft.com/info/copyright.htm"
<burki...@hotmail.com> wrote in message
news:b8aiqg$4pu$1...@news.state.mn.us...
--
This posting is provided "AS IS" with no warranties and confers no rights.
Use of any included samples is subject to the terms specified at
http://www.microsoft.com/info/copyright.htm"
"krish shenoy[MS]" <ksh...@online.microsoft.com> wrote in message
news:uPfhSs0C...@TK2MSFTNGP11.phx.gbl...
Before the certificate is returned to the client, the client sent a PKCS10
request to the CA I write.
And the PKCS10 is generated by IE. The RSA public key is sent to the CA
and private key is stored in the browser.
Thus, the client does have the private key.
> ----------------- END VBS --------------------
> <burki...@hotmail.com> wrote in message news:b8aiqg$4pu$1...@news.state.mn.us...