Show / Hide Table of Contents

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.

C#
public bool TrySetPin()

Returns

bool

A boolean, true if the PIN is set, false if the user cancels PIN collection.

Exceptions

Type Condition
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.

C#
public bool TrySetPin(ReadOnlyMemory<byte> pin)

Parameters

Type Name Description
ReadOnlyMemory<byte> pin

Returns

bool

A boolean, true if the PIN is set, false if the user cancels PIN collection.

Exceptions

Type Condition
SecurityException

The U2F application is already set with a PIN, or the PIN is blocked.

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.

In this article
Back to top Generated by DocFX