TrySetPin Method
TrySetPin()
Tries to set the initial FIDO2 PIN using the KeyCollector
. To change an existing PIN, use
the TryChangePin() function.
public bool TrySetPin()
Returns
True
on success, False
if the user cancelled PIN collection, and an exception for all
other kinds of failures.
Exceptions
Type | Condition |
---|---|
System.Security.SecurityException | The YubiKey already has a PIN set. This function cannot be used to change the PIN. |
Remarks
The Yubikey is manufactured with no default PIN set on the FIDO2 application. To initially configure a PIN, use this function. This function will only succeed if no PIN is currently configured. To change an already set PIN, use the ChangePin() method instead. Once set, a PIN cannot be removed without resetting the FIDO2 application. This operation will unset the PIN as well as 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.
TrySetPin(ReadOnlyMemory<Byte>)
Tries to set the initial FIDO2 PIN. To change an existing PIN, use the TryChangePin() function.
public bool TrySetPin(ReadOnlyMemory<byte> newPin)
Parameters
Type | Name | Description |
---|---|---|
System.ReadOnlyMemory<System.Byte> | newPin | The PIN to program onto the YubiKey. It must be encoded in UTF-8 with Normalization Form C. It must be at least 4 Unicode code points in length, and not to exceed 63 bytes in encoded length. Read more about PINs here. |
Returns
True
on success, False
if the YubiKey has a PIN already set, and an exception for all
other kinds of failures.
Remarks
The Yubikey is manufactured with no default PIN set on the FIDO2 application. To initially configure a PIN, use this function. This function will only succeed if no PIN is currently configured. To change an already set PIN, use the ChangePin() method instead. Once set, a PIN cannot be removed without resetting the FIDO2 application. This operation will unset the PIN as well as clear all registered credentials.