Egov.Extensions.Configuration 8.0.3

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

Egov Configuration Extension

This package provides helpers for certificate loading and configuring IOptions<SystemCertificateOptions> in ASP.NET Core 8.0+ applications. This is a base library that serves as a foundation for other NuGet packages in the Egov ecosystem, providing shared certificate management functionality.

Getting Started

Please go through the following instructions to integrate certificate loading into your project.

Prerequisites

Before using this package, ensure you have:

  • A valid certificate file (PFX, CER, or PEM format)
  • Access to the certificate password if the certificate is password-protected
  • For Kubernetes deployments, certificates mounted as secrets with tls.crt and tls.key files

Installing

Install the following package from NuGet

Install-Package Egov.Extensions.Configuration

Then follow the instructions from Configuration and Usage sections below.

Configuration

Add the following configuration section to your appsettings.json:

{
   ...
   "Certificate": {
      "Path": "Files\\Certificates\\yourcertificate.pfx",
      "Password": "yourcertificatepassword"
   }
   ...
}

Path can be:

  • A path to a PFX file (requires Password)
  • A path to a CER file (for public certificates only)
  • A path to a directory containing tls.crt and tls.key files (for Kubernetes mounted secrets)

Password is optional and only required for encrypted PFX files or encrypted PEM private keys.

Usage

Add the following code snippet to your Program.cs or Startup.ConfigureServices method:

builder.Services.AddSystemCertificate(builder.Configuration.GetSection("Certificate"));

Then inject IOptions<SystemCertificateOptions> or IOptionsSnapshot<SystemCertificateOptions> into your services:

public class MyService
{
    private readonly SystemCertificateOptions _certificateOptions;

    public MyService(IOptions<SystemCertificateOptions> certificateOptions)
    {
        _certificateOptions = certificateOptions.Value;
    }

    public void UseCertificate()
    {
        var certificate = _certificateOptions.Certificate;
        // Use the certificate...
    }
}
Using CertificateLoader Directly

You can also use the CertificateLoader class directly without dependency injection:

Loading a public certificate:

var certificate = CertificateLoader.Public("path/to/certificate.cer");

Loading a private certificate:

var certificate = CertificateLoader.Private("path/to/certificate.pfx", "password");

Loading from Kubernetes mounted secret:

var certificate = CertificateLoader.Private("/etc/ssl/certs", null);

The CertificateLoader automatically handles:

  • Loading certificates from PFX files
  • Loading certificates from CER files
  • Loading certificates from PEM files (including certificate chains)
  • Loading certificates from Kubernetes mounted secrets (tls.crt and tls.key)
  • Installing intermediate certificates into the certificate store

Supported Certificate Formats

  • PFX/PKCS#12: Password-protected certificate with private key
  • CER: Public certificate file
  • PEM: Certificate chain files (supports tls.crt and tls.key for Kubernetes)

Error Handling

If the certificate cannot be loaded or does not contain a private key (when required), the package will throw an InvalidOperationException with an appropriate error message.

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.
  • net8.0

    • No dependencies.

NuGet packages (2)

Showing the top 2 NuGet packages that depend on Egov.Extensions.Configuration:

Package Downloads
Egov.Integrations.MPass.Saml

This package contains an authentication handler for MPass implementing SAML 2.0 protocol for ASP.NET Core.

Egov.Integrations.MSign.Soap

A reusable library to connect with MSign. Usage: in Startup.cs on ConfigureServices add services.AddMSignSoapClient(Configuration.GetSection("MSignSoap"));

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
8.0.3 225 12/12/2025