Yubico NG

Enables integration with the Yubico validation platform, so you can use Yubikey's one-time-password in your Rust application, allowing a user to authenticate via Yubikey.
Current features
- Synchronous Yubikey client API library, validation protocol version 2.0.
- Asynchronous Yubikey client API library relying on Tokio
Note: The USB-related features have been moved to a separated repository, yubico-manager
Usage
Add this to your Cargo.toml
[]
= "0.14"
Or, since this crate is still backwards compatible with the yubico crate.
[]
= { = "0.14", = "yubico_ng" }
The following are a list of Cargo features that can be enabled or disabled:
- online-tokio (enabled by default): Provides integration to Tokio using futures.
- native-tls (enabled by default): Use native-tls provided by the OS.
- rustls-tls: Use rustls instead of native-tls.
You can enable or disable them using the example below:
[]
= "0.13"
# don't include the default features (online-tokio, native-tls)
= false
# cherry-pick individual features
= []
OTP with Default Servers
extern crate yubico_ng;
use *;
use verify;
OTP with custom API servers
use verify;
use Config;
Asynchronous OTP validation
use TryFutureExt;
use stdin;
use Config;
use verify_async;
async
Docker
For convenience and reproducibility, a Docker image can be generated via the provided repo's Dockerfile.
General
You can use a build-arg to select which example to be used. For example use --build-arg=EXAMPLE=otp_async to build the async example instead of the default otp example.
Build:
Run:
Static
A static binary can be extracted from the container and run on almost any Linux system.
Build:
Run:
Changelog
-
0.15.0 (2026-01-18):
- Use reqwest v0.13 or higher
- Switched to edition 2024
- Set MSRV to v1.85.0 which supports edition 2024 by default
- Removed
native-tlsandrustls-tlsand usereqwest/default-tlsby default. All other reqwest features are disabled in this crate it self!
Hightlights
In this version I removed the specific
reqwestfeatures because it would limitreqwestto those specific features. Also updated toreqwestv0.13 as a minimal version. If you need to use v0.12 ofreqwest, just keep using v0.14 ofyubico_ng. I default to thedefault-tlsfeature via thedefaultfeature of the crate it self, which should be fine for most use cases.If you want to use anything else besides
default-tls, usedefault-features = false, definereqwestas a custom dependency and define the wanted features. This way you can userustls-no-providerand use any provider supported byreqwest.[] = { = "0.15", = false, = ["online-tokio"] } = { = "0.13.1", = false, = ["rustls-no-provider"] } = { = "0.23.36", = false, = ["ring"] } -
0.14.1 (2025-08-13):
- Exclude several files from the crate package
-
0.14.0 (2025-08-13) (not published to crates.io):
- Upgrade to
tokio1.47 - Bumped MSRV to v1.82.0 needed by latest packages
- Added more clippy/rust lints including
pedanticand fixed found items - Use only the main api server, the others are deprecated
- Updated GHA
- Added dotenvy as a dev dependency to load
.envfiles
- Upgrade to
-
0.13.0 (2025-04-23):
- Upgrade to
tokio1.44,rand0.9 - Renamed to yubico_ng and published crate
- Made edition 2024 compatible
- Added several clippy/rust lints and fixed those
- Fixed a panic if the
YK_API_HOSTwas invalid - Use only the main api server, the others are deprecated
- Run cargo fmt
- Updated GHA to use hashes and run/fix zizmor
- Upgrade to
-
0.12.0: Upgrade to
tokio1.37,reqwest0.12,base640.22, clippy fixes. -
0.10.0: Upgrade to
tokio1.1 andreqwest0.11 -
0.9.2: (Yanked) Dependencies update
-
0.9.1: Set HTTP Proxy (Basic-auth is optional)
-
0.9.0: Moving to
tokio0.2 andreqwest0.10 -
0.9.0-alpha.1: Moving to
futures0.3.0-alpha.19 -
0.8: Rename the
syncandasyncmodules tosync_verifierandasync_verifierto avoid the use of theasyncreserved keyword.