Show / Hide Table of Contents

FindByTransport Method

FindByTransport(Transport)

Enumerate YubiKeys over the given transports.

C#
public static IEnumerable<IYubiKeyDevice> FindByTransport(Transport transport = Transport.All)

Parameters

Type Name Description
Transport transport

Argument controls which devices are searched for. Values None will result in exceptions being thrown. FindAll() is a convenience function to find All.

Returns

IEnumerable<IYubiKeyDevice>

A collection of YubiKeys that were found, as IYubiKeyDevices.

Exceptions

Type Condition
ArgumentException

Thrown when transport is None.

UnauthorizedAccessException

Thrown when attempting to find YubiKeys for the transport HidFido on Windows, and the application is not running in an elevated state (e.g. "Run as administrator").

Remarks

This method will exclude any connection (SmartCard, HidFido, HidKeyboard) that did not successfully respond to a request for its Firmware Version. This means that there may be fewer IYubiKeys returned than expected, or that some IYubiKeys are missing an expected connection.

To the host device, a single YubiKey can appear as multiple devices. This method will attempt to match these devices back together into a single IYubiKeyDevice using their serial number. If they cannot be matched, each connection will be returned as a separate IYubiKeyDevice.

If your application no longer needs to watch for insertion or removal notifications, you can call StopListening() to release resources and avoid the logging and other actions from the listeners.

In this article
Back to top Generated by DocFX