[prev in list] [next in list] [prev in thread] [next in thread] 

List:       ms-cryptoapi
Subject:    Re: How to import a certificate in a store???
From:       "John Lambert (NT)" <johnla () WINDOWS ! MICROSOFT ! COM>
Date:       2002-08-12 19:45:03
[Download RAW message or body]


You can write a capicom script to do the same thing:

Dim oStoreSC
Dim oStoreMy
Dim oCerts
Dim oCert
Dim oProp
Const CAPICOM_SMART_CARD_USER_STORE = 4
Const CAPICOM_STORE_OPEN_READ_ONLY = 0 
Const CAPICOM_CERT_INFO_SUBJECT_SIMPLE_NAME = 0
Const CAPICOM_MY_STORE = "My"
Const CAPICOM_CURRENT_USER_STORE = 2
Const CAPICOM_STORE_OPEN_READ_WRITE = 1

Set oStoreSC = CreateObject("CAPICOM.Store")

WScript.stdout.WriteLine "Opening up the smart card..."
oStoreSC.Open CAPICOM_SMART_CARD_USER_STORE, CAPICOM_MY_STORE,  \
CAPICOM_STORE_OPEN_READ_ONLY

Set oCerts = oStoreSC.Certificates

If oCerts.Count = 0 Then
    WScript.stdout.WriteLine "There are no certificates on the smart card."
    WScript.Quit(-1)
Else
    Set oCert = oCerts.Item(1)      'just deal with the first cert you find
    WScript.stdout.WriteLine "Propping certificate to the My store."
    WScript.stdout.WriteLine "  Subject Simple Name: " & oCert.GetInfo \
(CAPICOM_CERT_INFO_SUBJECT_SIMPLE_NAME)  WScript.stdout.WriteLine "  Thumbprint       \
: " & oCert.Thumbprint  WScript.stdout.WriteLine "  Valid To           :  " & \
oCert.ValidToDate

    'Now, open up the My store to add the cert
    Set oStoreMy = CreateObject("CAPICOM.Store")
    oStoreMy.Open CAPICOM_CURRENT_USER_STORE, CAPICOM_MY_STORE, \
CAPICOM_STORE_OPEN_READ_WRITE  oStoreMy.Add oCert
    WScript.stdout.WriteLine "Certificate Added."
End If

John

-----Original Message-----
From: Laszlo Elteto [mailto:lelteto@RAINBOW.COM] 
Sent: Monday, August 12, 2002 8:18 AM
To: CryptoAPI@DISCUSS.MICROSOFT.COM
Subject: Re: How to import a certificate in a store???

1. Get your certificate from the smart card
2. CertOpenStore ("MY")
3. CertCreateCertificateContext
4. CertSetCertificateContextProperty (CERT_FRIENDLY_NAME_PROP_ID optional)
5. CertSetCertificateContextProperty (CERT_KEY_PROV_INFO_PROP_ID to your
CSP)
6. CertAddCertificateContextToStore
(Actually, just to make sure I repeat 4 and 5 with the in-store certificate
context) Of course, don't forget to free your certificate context (both).
Hope this helps...

Laszlo Elteto
Fellow Scientist
Rainbow Technologies, Inc.

-----Original Message-----
From: Ivan Basart [mailto:ivan.basart@ES.GI-DE.COM]
Sent: Monday, August 12, 2002 3:01 AM
To: CryptoAPI@DISCUSS.MICROSOFT.COM
Subject: How to import a certificate in a store???


Hi everybody!

I'm new using CryptoAPI and there are some questions which are fuzzy to me.
I wan' t to sign using a Certificate stored in a SmartCard, I think that the
ussual way to do it is to import the certificate in the MY store and then
open that store. The problem is that I have no idea on how to import a
certificate in a store and in my case moreover the certificate is stored in
a smartcard.

Plese can anyone help me???

Thanks


*       Ivan Basart Carrillo - ivan.basart@es.gi-de.com
*       Dept. Marketing & Development.
*       GyD Ibérica - Giesecke & Devrient 
*       Timbal del Bruc, 4A
*       E-08970 - St. Joan Despí
*       Tel. +34 93 480 83 03 (Ext. 353)

----------------------------------------------------------------
Users Guide http://discuss.microsoft.com/archives/mailfaq.asp
contains important info. Save time, search the archives at
http://discuss.microsoft.com/archives/index.html .
To unsubscribe, mailto:CryptoAPI-signoff-request@DISCUSS.MICROSOFT.COM

----------------------------------------------------------------
Users Guide http://discuss.microsoft.com/archives/mailfaq.asp
contains important info. Save time, search the archives at
http://discuss.microsoft.com/archives/index.html .
To unsubscribe, mailto:CryptoAPI-signoff-request@DISCUSS.MICROSOFT.COM

----------------------------------------------------------------
Users Guide http://discuss.microsoft.com/archives/mailfaq.asp
contains important info. Save time, search the archives at
http://discuss.microsoft.com/archives/index.html .
To unsubscribe, mailto:CryptoAPI-signoff-request@DISCUSS.MICROSOFT.COM


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic