Xojo Plugin
Xojo Plugin
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 Xojo Plugin Downloads
Dim success As Boolean
success = False
// Note: Requires Chilkat v9.5.0.77 or greater.
Dim cert As New Chilkat.Cert
cert.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.
success = cert.LoadFromSmartcard("")
If (success <> True) Then
System.DebugLog(cert.LastErrorText)
Return
End If
// Check to see if the SmartCardPin property contains the valid PIN for the smartcard.
Dim pinValid As Int32
pinValid = cert.CheckSmartCardPin()
If (pinValid < 0) Then
System.DebugLog("Unable to check the PIN validity.")
System.DebugLog(cert.LastErrorText)
Return
End If
If (pinValid = 1) Then
System.DebugLog("PIN is valid.")
Else
System.DebugLog("PIN is invalid.")
End If