Certificate Services Issue

M

Millhouse

I am trying to find a way to take a certificate that i have issued in
the certificate services server and take it out of the server to turn
it into a .cer file which I can then put in the CA and download a .pfx
file. Right now I have no clue on how to download the .cer aka get the
issued cert out of the certificate services server. I tried to grab the
binary cert object, but it's encoded in base64 and I don't even know if
it'll be usefull once i decode it. If anyone knows of any objects that
could help me pull the issued cert out of the certificate services
server it would be greatly appreciated. Thanks for the help in advance.

Const CR_IN_FORMATANY = 0
Const CC_DEFAULTCONFIG = 0
Const CR_IN_ENCODEANY = 255

Const CAPICOM_STORE_SAVE_AS_PFX = 2
'Const CAPICOM_LOCAL_MACHINE_STORE = 1
Const CAPICOM_STORE_OPEN_READ_ONLY = 0
'Const CAPICOM_CURRENT_USER_STORE = 2
Const CAPICOM_CERTIFICATE_FIND_SHA1_HASH = 0
Const CAPICOM_CERT_INFO_SUBJECT_SIMPLE_NAME = 0
Const CAPICOM_EXPORT_IGNORE_PRIVATE_KEY_NOT_EXPORTABLE_ERROR = 1

Const CAPICOM_MEMORY_STORE = 0
Const CAPICOM_LOCAL_MACHINE_STORE = 1
Const CAPICOM_CURRENT_USER_STORE = 2
Const CAPICOM_ACTIVE_DIRECTORY_USER_STORE = 3
Const CAPICOM_SMART_CARD_USER_STORE = 4

Const CR_PROP_CASIGCERTCOUNT = 11
Const CR_PROP_CASIGCERT = 12
Const PROPTYPE_LONG = 1
Const PROPTYPE_BINARY = 3
Const CV_OUT_BINARY = 2

Const CAPICOM_CERT_INFO_SUBJECT_EMAIL_NAME = 2

Const CVRC_TABLE_REQCERT = 0

Const CV_OUT_BASE64 = 1
Const DB_DISP_ISSUED = 20
Const CVR_SEEK_GT = 16
Const CVR_SORT_DESCEND = 2

Set objEnroll = CreateObject("CEnroll.CEnroll.1")
Set CertRequest = CreateObject("CertificateAuthority.Request")
Set CertAdmin = CreateObject("CertificateAuthority.Admin")
Set CertConfig = CreateObject("CertificateAuthority.Config")
Set CertView = CreateObject("CertificateAuthority.View")
Set CAPCert = CreateObject("CAPICOM.Certificate")
Set Store = CreateObject("CAPICOM.Store")

Set Certi = CreateObject("CAPICOM.Certificate")

intIndex = CertView.GetColumnIndex(False, "RequestID")
CertView.SetRestriction intIndex, CVR_SEEK_GT, CVR_SORT_DESCEND, 0

Set objRow = CertView.OpenView

Do Until objRow.Next = -1
Set objCol = objRow.EnumCertViewColumn()
Set objAttrib = objRow.EnumCertViewAttribute(0)

Do Until objCol.Next = -1
'wscript.echo objcol.getdisplayname
Select Case objCol.GetDisplayName

Case "Issued Request ID"
ReqID =
clng(objCol.GetValue(CV_OUT_BASE64))
'wscript.echo ReqID

Case "Issued Common Name"
ComName =
objCol.GetValue(CV_OUT_BASE64)

Case "Binary Certificate"
BinCert =
objCol.GetValue(CV_OUT_BASE64)
'wscript.echo bincert
End Select
Loop
If ReqID = ID Then
CAPCert.Import BinCert
pfxoutfile = ComName + "pk12.cer"
'CAPCert.Save pfxoutfile, "newPFXpass" ,
CAPICOM_STORE_SAVE_AS_PFX,
ExportFlag
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top