(PureBasic) Load Certificate from Smartcard in Reader (or from USB Token)
Demonstrates how to load the certificate that is on the smartcard currently inserted into the smartcard reader. (Also can load the smartcard on a USB token.)
IncludeFile "CkCert.pb"
Procedure ChilkatExample()
cert.i = CkCert::ckCreate()
If cert.i = 0
Debug "Failed to create object."
ProcedureReturn
EndIf
; If you know the smart card PIN, set it prior to loading from the smartcard/USB token.
CkCert::setCkSmartCardPin(cert, "12345678")
; Pass an empty string to allow Chilkat to discover the smart card or USB token automatically.
success.i = CkCert::ckLoadFromSmartcard(cert,"")
If success = 0
Debug CkCert::ckLastErrorText(cert)
CkCert::ckDispose(cert)
ProcedureReturn
EndIf
Debug "Cert loaded from smartcard: " + CkCert::ckSubjectCN(cert)
CkCert::ckDispose(cert)
ProcedureReturn
EndProcedure
|