I am using Win2000 prof.
I created few certificates using makecert.exe for
different windows users under LocalMachine hive with some
store name,
i.e
1 certificate for Admin(using Admin login)
1 certificate for testuser1(using testuser1 login)
1 certificate for testuser2(using testuser2 login)
now i want to access all these certificates from my ASP
page using CAPICOM.
I could see the count of certificates. But when i wanted
to sign a message it fails.
From ASP I could not even use Admin certificate for
signing.
CAPICOM error found : -2146885621
Cannot find the certificate and private key for decryption.
(But,This works fine in a stand alone VB application)
Please help me.Following is the code i am using in my ASP
page.
(Note: I have granted access permissions to IUSR_GUEST on
the certificate store using winhttpcertcfg tool.Still I 'm
not able to use the certificates.)
Please help me.
Dim LocalStore
set LocalStore = Server.CreateObject("CAPICOM.Store")
Dim i
LocalStore.Open CAPICOM_LOCAL_MACHINE_STORE ,
StoreName,CAPICOM_STORE_OPEN_READ_ONLY
CertFound = False
For i = 1 To LocalStore.Certificates.Count
If LocalStore.Certificates.Item(i).GetInfo
(CAPICOM_INFO_SUBJECT_SIMPLE_NAME) = SubjectName Then
If LocalStore.Certificates.Item(i).HasPrivateKey
Then
Set SignerCert = LocalStore.Certificates.Item
(i)
CertFound = True
Exit For
End If
End If
Next
'**************************************
Dim MessageSigner
set MessageSigner = Server.CreateObject("CAPICOM.Signer")
Dim SignObj
set SignObj = Server.CreateObject("CAPICOM.SignedData")
Dim SignedMessageString
Dim ByteArray
MessageSigner.Certificate = SignerCert
SignObj.Content = "This is test content to sign"
SignedMessageString = SignObj.Sign(MessageSigner)
tempSignedMessage = SignedMessageString
Response.Write("tempSignedMessage ---" & tempSignedMessage
& "<br>")
Set SignerCert = Nothing