Egov.XmlSigning 10.0.1

Prefix Reserved
There is a newer version of this package available.
See the version list below for details.
dotnet add package Egov.XmlSigning --version 10.0.1
                    
NuGet\Install-Package Egov.XmlSigning -Version 10.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="Egov.XmlSigning" Version="10.0.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Egov.XmlSigning" Version="10.0.1" />
                    
Directory.Packages.props
<PackageReference Include="Egov.XmlSigning" />
                    
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.XmlSigning --version 10.0.1
                    
#r "nuget: Egov.XmlSigning, 10.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 Egov.XmlSigning@10.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=Egov.XmlSigning&version=10.0.1
                    
Install as a Cake Addin
#tool nuget:?package=Egov.XmlSigning&version=10.0.1
                    
Install as a Cake Tool

Egov.XmlSigning

NuGet License: MIT

A .NET library providing extension methods for signing, verifying, encrypting and decrypting SOAP envelopes and XML documents according to the WS-Security standard. It targets .NET 10.0+.


Table of Contents


Features

  • WS-Security signing and signature validation for SOAP envelopes
  • Envelope encryption and decryption, including optional signature encryption
  • Message freshness checks via time-to-live and allowed clock skew
  • Works with both XDocument and XmlDocument
  • Conversion and traversal helpers between the two XML APIs

Prerequisites

  • .NET 10.0 SDK or later
  • An X.509 certificate with a private key for signing/decryption, and the counterparty's public certificate for verification/encryption

Installation

dotnet add package Egov.XmlSigning

Usage

Signing a SOAP Envelope

using Egov.XmlSigning.Soap;

var envelope = XDocument.Parse(soapXml);
var signed = envelope.SignSoapEnvelope(privateCertificate, timeToLive: TimeSpan.FromMinutes(5));

timeToLive stamps the WS-Security timestamp the recipient validates against. Two optional parameters are available: useSha1 (defaults to false — leave it off unless a legacy counterparty demands SHA-1) and tokenReference, which selects how the signing certificate is referenced (BinarySecurityToken by default).

Verifying a Signature

using Egov.XmlSigning.Soap;

var isValid = envelope.ValidateSoapEnvelopeSignature(
    trustedCertificates: [partnerPublicCertificate],
    timeToLive: TimeSpan.FromMinutes(5),
    allowedClockSkew: TimeSpan.FromMinutes(10));

if (!isValid)
{
    throw new SecurityException("SOAP envelope signature is not valid.");
}

timeToLive bounds how long a signed message stays acceptable; allowedClockSkew tolerates clock drift between the two systems. Both must be supplied deliberately — do not widen them to work around a clock problem you have not diagnosed.

Encryption and Decryption

using Egov.XmlSigning.Soap;

// Encrypt for the recipient, including the signature by default.
var encrypted = envelope.EncryptSoapEnvelope(recipientPublicCertificate);

// Encrypt leaving the signature in the clear.
var partiallyEncrypted = envelope.EncryptSoapEnvelope(recipientPublicCertificate, encryptSignature: false);

// Decrypt with your own private key.
var decrypted = encrypted.DecryptSoapEnvelope(privateCertificate);

XML Helpers

Egov.XmlSigning.Xml provides conversion between XDocument and XmlDocument (XmlConversionExtensions) and element traversal helpers (XElementExtensions), useful when bridging APIs that expect one representation or the other.


Testing

dotnet test src/Egov.XmlSigning.sln

The test project uses NUnit and ships self-signed certificates under src/Egov.XmlSigning.Tests/Certificates/ for round-trip signing and encryption tests. These are test fixtures only and must never be used outside the test suite.


Changelog

See CHANGELOG.md for what changed in each release.

Contributing

See CONTRIBUTING.md.

Code of Conduct

See CODE_OF_CONDUCT.md.

AI Assistance

See AGENTS.md for guidance aimed at AI coding assistants.

License

Distributed under the MIT License. See LICENSE.

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  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
10.0.2 148 10/30/2026
10.0.1 177 10/12/2026