BelgianEid 1.0.1

dotnet add package BelgianEid --version 1.0.1
                    
NuGet\Install-Package BelgianEid -Version 1.0.1
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="BelgianEid" Version="1.0.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="BelgianEid" Version="1.0.1" />
                    
Directory.Packages.props
<PackageReference Include="BelgianEid" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add BelgianEid --version 1.0.1
                    
#r "nuget: BelgianEid, 1.0.1"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package BelgianEid@1.0.1
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=BelgianEid&version=1.0.1
                    
Install as a Cake Addin
#tool nuget:?package=BelgianEid&version=1.0.1
                    
Install as a Cake Tool

BelgianEid

NuGet Downloads .NET License: MIT

.NET 8 library for the Belgian electronic identity card (eID) over PKCS#11: read identity / address / photo, read the X.509 certificates, verify the PIN, produce electronic signatures, run challenge-response authentication, and check certificate revocation via OCSP / CRL. Dependency-injection first and fully mockable (every operation sits behind an interface).

Full documentation, browser bridge/extension, installer and source code: https://github.com/isnow-git/belgian-eid

Install

dotnet add package BelgianEid

Native middleware (required)

This package talks to the card through the Belgian eID middleware's native PKCS#11 library (beidpkcs11). For licensing reasons (LGPLv3) the package does not bundle it. Provide it in any one of these ways:

  1. Install the official middleware system-wide (recommended) from https://eid.belgium.be — most cardholders already have it. The library then loads beidpkcs11 from the operating system search path automatically.

  2. Point at an explicit path: options.Pkcs11LibraryPath = @"C:\Program Files\Belgium Identity Card\FireFox-Plugins\beidpkcs11.dll";

  3. Ship the native library next to your app under native/<rid>/ and the library resolves it automatically:

    Platform RID File name
    Windows x64 win-x64 beidpkcs11.dll
    Windows x86 win-x86 beidpkcs11.dll
    Linux x64 linux-x64 libbeidpkcs11.so
    macOS Intel osx-x64 libbeidpkcs11.dylib
    macOS Apple Silicon osx-arm64 libbeidpkcs11.dylib

    Download the native libraries from https://eid.belgium.be or https://github.com/Fedict/eid-mw. Resolution order: explicit path → bundled native/<rid>/ → operating system path.

Quick start

using BelgianEid.Abstractions;
using BelgianEid.DependencyInjection;
using BelgianEid.Models;
using Microsoft.Extensions.DependencyInjection;
using System.Security.Cryptography;

await using var provider = new ServiceCollection()
    .AddBelgianEid()
    .BuildServiceProvider();

var client = provider.GetRequiredService<IEidClient>();

// Open a session on the first reader that holds a card.
using IEidSession session = client.OpenSession();

// Read every field in one call.
EidCardData card = client.ReadCardData(session);
Console.WriteLine($"{card.Identity.FirstNames} {card.Identity.LastName}");
Console.WriteLine($"{card.Address.Street}, {card.Address.ZipCode} {card.Address.Municipality}");

// Sign a server challenge with the authentication key.
byte[] challenge = RandomNumberGenerator.GetBytes(32);
AuthenticationResult auth = await client.AuthenticateAsync(session, challenge, pin: "1234");
// auth.Signature                 → byte[]
// auth.AuthenticationCertificate → X509Certificate2  (send this to the server)

// Check the authentication certificate against the Belgian OCSP responder.
OcspResult ocsp = await client.ValidateCertificateAsync(session, EidCertificateKind.Authentication);
Console.WriteLine(ocsp.IsValid ? "Certificate valid" : $"Revoked on {ocsp.RevocationTime:d}");

Without a DI container, the services can be constructed directly — see the full library guide.

Configuration

services.AddBelgianEid(options =>
{
    options.Pkcs11LibraryPath = @"C:\path\to\beidpkcs11.dll"; // optional explicit path
    options.OcspTimeout       = TimeSpan.FromSeconds(10);
});
Option Default Purpose
Pkcs11LibraryPath null (auto-detect) Explicit path to the native beidpkcs11 library.
BundledNativeDirectory "native" Folder holding per-RID native binaries.
OcspResponderUrl http://ocsp.eidpki.belgium.be/eid/0 Belgian OCSP responder (fallback when no AIA).
OcspTimeout 00:00:15 Maximum wait for an OCSP response.

Error handling

All exceptions derive from EidException (namespace BelgianEid.Exceptions):

Exception Thrown when
EidConfigurationException beidpkcs11 not found or cannot be loaded
EidReaderNotFoundException No PC/SC reader detected
EidCardNotPresentException No eID card in the reader
EidPinIncorrectException Wrong PIN — RemainingAttempts says how many are left
EidPinBlockedException PIN blocked after 3 failures
EidCertificateRevokedException Certificate revoked — RevocationTime holds the date
EidCommunicationException Card or OCSP/CRL communication failure
EidDataNotFoundException Expected data object / certificate absent from the card

License

MIT — see the LICENSE. The native beidpkcs11 middleware is LGPLv3 (SPF BOSA); see THIRD-PARTY-NOTICES.

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.1 148 6/9/2026
1.0.0 119 6/9/2026