Show / Hide Table of Contents

SetPin Method

SetPin()

Sets the initial FIDO2 PIN using the KeyCollector. To change an existing PIN, use the ChangePin() function.

C#
public void SetPin()

Exceptions

Type Condition
SecurityException

The YubiKey already has a PIN set. This function cannot be used to change the PIN.

OperationCanceledException

The user cancelled PIN collection. This happens when the application returns false in the KeyCollector.

Remarks

The Yubikey is manufactured with no default PIN set on the FIDO2 application. To configure a YubiKey's initial PIN, use this function. This function will only succeed if no PIN is currently configured. To change an existing PIN, use the ChangePin() method instead. Once set, a PIN cannot be removed without resetting the FIDO2 application. The reset operation will remove the PIN and clear all registered credentials.

Several considerations must be made when collecting the PIN.

  • It must be encoded in UTF-8 with Normalization Form C.
  • It must be at least 4 Unicode code points in length.
  • It must not exceed 63 bytes in encoded length.
Read more about PINs here.
In this article
Back to top Generated by DocFX