DataFlex
DataFlex
Import a Certificate (.cer file) into a Windows Certificate Store
See more Certificates Examples
Demonstrates how to import a certificate (without private key) into a Windows certificate store.Chilkat DataFlex Downloads
Use ChilkatAx-win32.pkg
Procedure Test
Boolean iSuccess
Variant vCert
Handle hoCert
Handle hoCertStoreCU
Boolean iReadOnlyFlag
String sTemp1
Move False To iSuccess
Get Create (RefClass(cComChilkatCert)) To hoCert
If (Not(IsComObjectCreated(hoCert))) Begin
Send CreateComObject of hoCert
End
Get ComLoadFromFile Of hoCert "qa_data/certs/example.cer" To iSuccess
If (iSuccess = False) Begin
Get ComLastErrorText Of hoCert To sTemp1
Showln sTemp1
Procedure_Return
End
Get Create (RefClass(cComChilkatCertStore)) To hoCertStoreCU
If (Not(IsComObjectCreated(hoCertStoreCU))) Begin
Send CreateComObject of hoCertStoreCU
End
Move False To iReadOnlyFlag
// "CurrentUser" and "My" are the exact keywords to select your user account's certificate store.
Get ComOpenWindowsStore Of hoCertStoreCU "CurrentUser" "My" iReadOnlyFlag To iSuccess
If (iSuccess = False) Begin
Showln "Failed to open the CurrentUser/My certificate store for read/write."
Procedure_Return
End
// Import the certificate into the CurrentUser/My certificate store.
Get pvComObject of hoCert to vCert
Get ComAddCertificate Of hoCertStoreCU vCert To iSuccess
If (iSuccess = False) Begin
Get ComLastErrorText Of hoCertStoreCU To sTemp1
Showln sTemp1
Procedure_Return
End
Get ComSubjectCN Of hoCert To sTemp1
Showln "Imported " sTemp1
Showln "Success."
End_Procedure