Xbase++
Xbase++
Validate a Smartcard PIN
See more Certificates Examples
Validates a smartcard PIN. This example only runs on Windows and requires Chilkat v9.5.0.77 or greater.Chilkat Xbase++ Downloads
LOCAL nSuccess
LOCAL oCert
LOCAL nPinValid
nSuccess := 0
// Note: Requires Chilkat v9.5.0.77 or greater.
oCert := CreateObject("Chilkat.Cert")
oCert:SmartCardPin := "000000"
// Load the certificate on the smartcard currently in the reader (or on the USB token).
// Pass an empty string to allow Chilkat to automatically choose the CSP (Cryptographi Service Provider).
// See Load Certificate on Smartcard for information about explicitly selecting a particular CSP.
nSuccess := oCert:LoadFromSmartcard("")
IF (nSuccess != 1)
? oCert:LastErrorText
oCert:destroy()
RETURN
ENDIF
// Check to see if the SmartCardPin property contains the valid PIN for the smartcard.
nPinValid := oCert:CheckSmartCardPin()
IF (nPinValid < 0)
? "Unable to check the PIN validity."
? oCert:LastErrorText
oCert:destroy()
RETURN
ENDIF
IF (nPinValid == 1)
? "PIN is valid."
ELSE
? "PIN is invalid."
ENDIF
oCert:destroy()