Show / Hide Table of Contents

GetMetadata Method

GetMetadata(byte)

Get information about the specified slot.

C#
public PivMetadata GetMetadata(byte slotNumber)

Parameters

Type Name Description
byte slotNumber

The slot for which the information is requested.

Returns

PivMetadata

A new instance of a PivMetadata object containing information about the given slot.

Exceptions

Type Condition
ArgumentException

The slot specified is not valid for getting metadata.

InvalidOperationException

The YubiKey queried does not support metadata, or the operation could not be completed because of some error such as unreliable connection.

Remarks

This feature is available only on YubiKeys 5.3 and later. If you call this method on an earlier YubiKey, it will throw an exception. A good idea is to verify that the version number is valid before calling.

IEnumerable<IYubiKeyDevice> list = YubiKey.FindByTransport(Transport.UsbSmartCard);
IYubiKeyDevice yubiKey = list.First();

using (var pivSession = new PivSession(yubiKey))
{
    if (yubiKey.FirmwareVersion >= new FirmwareVersion(5, 3, 0))
    {
        PivMetadata metadataSlot9A =
            pivSession.GetMetadata(PivSlot.Authentication);
    }
}

See the User's Manual entry on getting metadata for specific information about what information is returned. Different slots return different sets of data. That page also lists the valid slots for which metadata is available.

In this article
Back to top Generated by DocFX