TrySetPin Method
TrySetPin()
For a version 4 FIPS series YubiKey that does not have a PIN set,
this will call on the KeyCollector to obtain a PIN and
use it to set the U2F application with that PIN. If the caller
cancels (the return from the KeyCollector
is false
),
this will return false
.
public bool TrySetPin()
Returns
A boolean, true
if the PIN is set, false
if the user
cancels PIN collection.
Exceptions
Type | Condition |
---|---|
System.Security.SecurityException | The YubiKey is not version 4 FIPS series, or the U2F application is already set with a PIN, or the PIN is blocked. |
Remarks
See the documentation for SetPin() for more information on setting a PIN.
TrySetPin(ReadOnlyMemory<Byte>)
For a version 4 FIPS series YubiKey that does not have a PIN set,
this will try to set the PIN using the given pin
.
public bool TrySetPin(ReadOnlyMemory<byte> pin)
Parameters
Type | Name | Description |
---|---|---|
System.ReadOnlyMemory<System.Byte> | pin |
Returns
A boolean, true
if the PIN is set, false
if the user
cancels PIN collection.
Exceptions
Type | Condition |
---|---|
System.Security.SecurityException | The U2F application is already set with a PIN, or the PIN is blocked. |
System.NotSupportedException | The YubiKey is not version 4 FIPS series. |
Remarks
See the documentation for SetPin() for more information on setting a PIN.
If the input pin
is less than 6 or more than 32 bytes long,
this method will return false
. However, this method will throw
an exception if the U2F application is already set, the PIN is
blocked, or the YubiKey is not version 4 FIPS series.