Tago.Extensions.Security.Certificates 3.1.1-preview-20250701-01

This is a prerelease version of Tago.Extensions.Security.Certificates.
dotnet add package Tago.Extensions.Security.Certificates --version 3.1.1-preview-20250701-01
                    
NuGet\Install-Package Tago.Extensions.Security.Certificates -Version 3.1.1-preview-20250701-01
                    
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="Tago.Extensions.Security.Certificates" Version="3.1.1-preview-20250701-01" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Tago.Extensions.Security.Certificates" Version="3.1.1-preview-20250701-01" />
                    
Directory.Packages.props
<PackageReference Include="Tago.Extensions.Security.Certificates" />
                    
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 Tago.Extensions.Security.Certificates --version 3.1.1-preview-20250701-01
                    
#r "nuget: Tago.Extensions.Security.Certificates, 3.1.1-preview-20250701-01"
                    
#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 Tago.Extensions.Security.Certificates@3.1.1-preview-20250701-01
                    
#: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=Tago.Extensions.Security.Certificates&version=3.1.1-preview-20250701-01&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=Tago.Extensions.Security.Certificates&version=3.1.1-preview-20250701-01&prerelease
                    
Install as a Cake Tool

Tago.Extensions.Security.Certificates

Tago.Extensions.Security.Certificates is a .NET library providing cross-platform, dependency-free cryptographic certificate and key utilities. It is designed for .NET Standard 2.0 compatibility, enabling secure key import/export, certificate manipulation, and cryptographic operations without third-party libraries.

Features

  • .NET Standard 2.0 Support: Works on .NET Core, .NET Framework, and modern .NET runtimes.
  • Manual ASN.1 Encoding: Export/import of RSA and ECDsa keys in PKCS#1, PKCS#8, and EC formats using pure C#.
  • Certificate Utilities:
    • Load certificates from files, PEM, PFX, and stores
    • Export public/private keys in standard formats
    • Minimal, dependency-free implementation
  • SecurityKey Integration: Helpers for JWT and cryptographic key scenarios
  • Test Coverage: xUnit-based tests for all major features

Usage

Importing and Exporting Keys

using Tago.Extensions.Security.Certificates.Extensions;

// Export RSA private key (PKCS#1)
byte[] pkcs1 = rsa.ExportRSAPrivateKey();

// Export RSA private key (PKCS#8)
byte[] pkcs8 = rsa.ExportPkcs8PrivateKey();

// Export ECDsa private key (RFC 5915)
byte[] ec = ecdsa.ExportECPrivateKey();

// Export ECDsa private key (PKCS#8)
byte[] ecPkcs8 = ecdsa.ExportPkcs8PrivateKey();

Certificate Loading

using Tago.Extensions.Security.Certificates;

// Load from file or store
var cert = CertificateHelper.GetCertificateFromStore("subjectName");
var cert2 = CertificateHelper.GetCertificate("./certs/mycert.pfx", "password");

SecurityKey Utilities

using Tago.Extensions.Security.Utils;

var key = SecurityKeyUtils.GetSecurityKey("./certs/mycert.pfx", "password", "kid");

Limitations

  • CopyWithPrivateKey: Not supported in .NET Standard 2.0 due to platform API limitations. Throws PlatformNotSupportedException.
  • No Third-Party Dependencies: All ASN.1 and key handling is implemented in pure C#.

Building & Testing

  1. Clone the repository.
  2. Build the solution:
    dotnet build src/Tago.Extensions.Security.Certificates.sln
    
  3. Run tests:
    dotnet test src/xUnitTest/xUnitTest.csproj
    

Project Structure

  • src/Tago.Extensions.Security.Certificates/ — Main library
  • src/xUnitTest/ — Test project
  • certs/ — Example/test certificates

License

MIT License

Contributing

Contributions, issues, and feature requests are welcome! Please open an issue or submit a pull request.


Tago.Extensions.Security.Certificates — Secure, portable, and dependency-free cryptography for .NET.

Introduction

Tago.Extensions.Security.Certificates is a robust .NET library for cryptographic certificate and key management, designed for maximum compatibility and zero third-party dependencies. It enables secure key import/export, certificate manipulation, and cryptographic operations in .NET Standard 2.0 and later, using only built-in .NET APIs and manual ASN.1 encoding.

Getting Started

Installation

Clone or add the library to your solution. Reference the main project:

src/Tago.Extensions.Security.Certificates/Tago.Extensions.Security.Certificates.csproj

Dependencies

  • .NET Standard 2.0 or higher
  • No third-party cryptography libraries required

API Overview

Key Export/Import

  • Export RSA and ECDsa private keys in PKCS#1, PKCS#8, and EC formats
  • Export public keys in PKCS#1 format
  • Manual ASN.1 encoding for all supported formats

Certificate Utilities

  • Load certificates from PEM, PFX, DER, or Windows certificate store
  • Export certificates and keys for use in JWT, SAML, and other security scenarios

SecurityKey Integration

  • Helpers for creating Microsoft.IdentityModel.Tokens SecurityKey objects from certificates and keys

Build and Test

  1. Build the solution:
    dotnet build src/Tago.Extensions.Security.Certificates.sln
    
  2. Run the tests:
    dotnet test src/xUnitTest/xUnitTest.csproj
    

Example Usage

Exporting Keys

using Tago.Extensions.Security.Certificates.Extensions;

// Export RSA private key (PKCS#1)
byte[] pkcs1 = rsa.ExportRSAPrivateKey();

// Export RSA private key (PKCS#8)
byte[] pkcs8 = rsa.ExportPkcs8PrivateKey();

// Export ECDsa private key (RFC 5915)
byte[] ec = ecdsa.ExportECPrivateKey();

// Export ECDsa private key (PKCS#8)
byte[] ecPkcs8 = ecdsa.ExportPkcs8PrivateKey();

Loading Certificates

using Tago.Extensions.Security.Certificates;

// Load from file or store
var cert = CertificateHelper.GetCertificateFromStore("subjectName");
var cert2 = CertificateHelper.GetCertificate("./certs/mycert.pfx", "password");

SecurityKey Utilities

using Tago.Extensions.Security.Utils;

var key = SecurityKeyUtils.GetSecurityKey("./certs/mycert.pfx", "password", "kid");

Project Structure

  • src/Tago.Extensions.Security.Certificates/ — Main library
  • src/xUnitTest/ — Test project
  • certs/ — Example/test certificates

Limitations

  • CopyWithPrivateKey: Not supported in .NET Standard 2.0 due to platform API limitations. Throws PlatformNotSupportedException.
  • No Third-Party Dependencies: All ASN.1 and key handling is implemented in pure C#.

Contributing

Contributions, issues, and feature requests are welcome! Please open an issue or submit a pull request. All code should be dependency-free and compatible with .NET Standard 2.0 or higher.

License

MIT License


Tago.Extensions.Security.Certificates — Secure, portable, and dependency-free cryptography for .NET.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  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. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 is compatible. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (3)

Showing the top 3 NuGet packages that depend on Tago.Extensions.Security.Certificates:

Package Downloads
Tago.Extensions.HttpClient

Http Rest helper

Tago.Extensions.JwkUtils

Jwk extension

Tago.Extensions.AspnetCore.IndexesAsApi.Abstractions

Package Description

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
3.1.1-preview-20250701-01 489 7/22/2025
3.1.1-preview-20240401-01 712 4/30/2024
3.1.1-preview-20240101-01 77 4/21/2024
3.1.1-preview-20231020-01 399 11/2/2023
3.1.1-preview-20230528-01 550 5/31/2023
3.1.1-preview-20220516-01 362 5/16/2022
3.1.1-preview-20220515-01 203 5/15/2022
3.1.1-preview-20200917-01 1,431 9/17/2020
3.1.0-preview-1103 1,410 8/2/2020
3.1.0-preview-1102 394 7/5/2020
3.1.0-preview-11 1,119 6/23/2020
3.1.0-preview-10 423 6/22/2020
3.1.0-preview-09 429 6/19/2020
3.1.0-preview-07 533 6/19/2020
3.1.0-preview-06 459 6/18/2020
3.1.0-preview-05 406 6/18/2020
3.1.0-preview-04 341 6/18/2020
3.1.0-preview-03 348 6/18/2020
3.1.0-preview-02 1,099 2/13/2020
3.1.0-preview-01 532 2/5/2020
3.0.0-preview-03 992 1/26/2020
3.0.0-preview-02 517 1/10/2020
3.0.0-preview-01 694 11/27/2019
2.0.3-preview-03 585 9/28/2019
2.0.3-preview-02 497 9/24/2019
2.0.3-preview-01 456 9/24/2019
2.0.0-preview-1 475 9/23/2019