ResetApplication Method
ResetApplication()
Reset the PIV application to the default state.
public void ResetApplication()
Exceptions
Type | Condition |
---|---|
System.Security.SecurityException | The application could not be reset because of some error such as unreliable connection. |
Remarks
This will delete all keys and certs in all the asymmetric key slots other than F9, delete any added information to the data elements and set the PIN, PUK, and management key to their default values. That is, this will set the PIV application's state to what it was upon manufacture. See the User's Manual entries on the PIV PIN, PUK, and management key and data elements for more information on the defaults and data added to elements.
Note that this has no effect on the other YubiKey applications. This does NOT reset OTP, OATH, OpenPgp Card, FIDO U2F, or FIDO2.
Users will generally want to reset only if both the PIN and PUK are blocked. If a PIN has been blocked, it can only be restored using the PUK, but if the PUK is also blocked, there is no way to recover the PIN. Once there is no PIN, and no way to recover it, there is very little useful work the PIV application on a YubiKey can do. Resetting the application does not make the situation worse, but it does improve things somewhat, because the PIV application is usable again, just with new key pairs.
However, it is important to note that this method will reset the PIV application even if the PIN and/or PUK are not blocked. The YubiKey will not allow itself to be reset until both the PIN and PUK are blocked. This method will take steps necessary to block the PIN and PUK, then call on the YubiKey to reset.
Before attempting to reset a YubiKey Bio Multi-protocol Edition key with ResetApplication(), verify that the PIV application is not blocked from using this method by checking the ResetBlocked property. If the application is blocked, use DeviceReset().