B4X
B4X
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 B4X Downloads
Dim success As Boolean = False
' Note: Requires Chilkat v9.5.0.77 or greater.
Dim cert As ChilkatCert
cert.Initialize("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
Log(cert.LastErrorText)
Return
End If
' Check to see if the SmartCardPin property contains the valid PIN for the smartcard.
Dim pinValid As Int = cert.CheckSmartCardPin
If pinValid < 0 Then
Log("Unable to check the PIN validity.")
Log(cert.LastErrorText)
Return
End If
If pinValid = 1 Then
Log("PIN is valid.")
Else
Log("PIN is invalid.")
End If