Re: CAPICOM problem on decode

From: flor_lai@yahoo.com
Date: 06/18/02


Date: Tue, 18 Jun 2002 11:54:18 -0400
From: flor_lai@yahoo.com
To: Dum&Dumber <beau_afric@yahoo.com>


Here is the code

Set Certificate = CreateObject("CAPICOM.Certificate")
Certificate.Import (encrypted_string_in_base64)
if err.number > 0 then
 set Certificate = nothing
 response.write "Invalid Certificate encoding string"
else
 response.write "IsValid: " & Certificate.IsValid
 response.write "Subject Name: " & Certificate.SubjectName
 response.write "Simple name = " & Certificate.GetInfo(CAPICOM_CERT_INFO_SUBJECT_SIMPLE_NAME)
 response.write "Email name = " & Certificate.GetInfo(CAPICOM_CERT_INFO_SUBJECT_EMAIL_NAME)
 response.write "Issuer Name: " & Certificate.IssuerName
 response.write "Serial Number: " & Certificate.SerialNumber
end if

Dum&Dumber wrote:

> can you help me out by posting your ASP code for this please?
> am trying to do the same thing as you are...
>
> thx
>
> flor_lai@yahoo.com wrote in message news:<3D04B810.327CFEB@yahoo.com>...
> > I solved the problem.
> > I can use Import method under certificate object.
> > Thanks
> >
> >
> > flor_lai@yahoo.com wrote:
> >
> > > Thanks for help.
> > > It is great, i can read the file to decode and view the certificate information.
> > > Is it possible passing the encoded stirng directly instead of reading from the file?
> > >
> > > Florence
> > >
> > > Michel Gallant wrote:
> > >
> > > > Use the Certificate object in CAPICOM like this (vbs):
> > > >
> > > > Set Certificate = CreateObject("CAPICOM.Certificate")
> > > > Certificate.Load CertFile, Password
> > > > ....
> > > >
> > > > then get any properties on the certificate you wish. There is an
> > > > excellent example with CAPICOM 2 releae called CView.vbs which
> > > > show all the details.
> > > > - Mitch Gallant
> > > >
> > > > flor_lai@yahoo.com wrote:
> > > >
> > > > > hi.
> > > > > Is it possiable to use CAPICOM ( version 2.0 ) to decode the certificate file.?
> > > > >
> > > > > I have a certificate newcert.cer. This certificate is valid. If I double click on the file, I can
> > > > > view the certificate information such as version, key, serial number etc. If I open it in notepad,
> > > > > I saw the certificate coding in base64 format with certificate header and footer ( ----
> > > > > Certificate begin ----).
> > > > >
> > > > > I try the commend-line tool ( CertUtil.exe ) to decode the certificate, It works. I am wondering
> > > > > could I do it in programming.
> > > > >
> > > > > So, I try to use CAPICOM to work on . But I got there error on "ANS1 bad tag value met"
> > > > >
> > > > > Certificate info :
> > > > > -----BEGIN CERTIFICATE-----
> > > > > hk6JfkswEgYIKgMEBQYHCAkBAf8EAxYBNDANBgkqhkiG9w0BAQUFAAOBgQDP+X+w
> > > > > +CjSNYWvhcXb4nJO8kEP1ESNvOb8gkWcvWsx7B9W1pDnCncYK7UMxDNPJSlHp3M8
> > > > > vXqi4Lgo4Kj0rfIhlJHmG6LwIzmR/9tj8TTvvohiFLJhRyNNRVi6iXi8aPPR6LBA
> > > > > ........
> > > > > g5siIHoMowVVTLfd5HaoFt8VmyG9oPLsZz48lA==
> > > > > -----END CERTIFICATE-----
> > > > >
> > > > > the following is my coding
> > > > >
> > > > > Dim CM As New FileSystemObject
> > > > > Dim Context As TextStream
> > > > > Dim certdata As String
> > > > > Set Context = CM.OpenTextFile("d:\project\ldap\ldif\certnew.cer", ForReading, False)
> > > > > encrypted = Context.ReadAll
> > > > > Set Context = Nothing
> > > > > Set CM = Nothing
> > > > >
> > > > > Dim message As New EncryptedData
> > > > > message.SetSecret 0, CAPICOM_SECRET_PASSWORD
> > > > > message.Algorithm.Name = CAPICOM_ENCRYPTION_ALGORITHM_RC2
> > > > > message.Decrypt (varcertdata)
> > > > > Debug.Print message.Content
> > > > >
> > > > > Could anyone tell me how should I do. Is it possible to decode the certificate file by
> > > > > programming.( VB / ASP )
> > > > >
> > > > > Thanks for help. I am appreciated .
> > > > >
> > > > > Florence


Quantcast