![]() |
VOOZH | about |
dotnet add package Indice.Cryptography --version 8.4.0
NuGet\Install-Package Indice.Cryptography -Version 8.4.0
<PackageReference Include="Indice.Cryptography" Version="8.4.0" />
<PackageVersion Include="Indice.Cryptography" Version="8.4.0" />Directory.Packages.props
<PackageReference Include="Indice.Cryptography" />Project file
paket add Indice.Cryptography --version 8.4.0
#r "nuget: Indice.Cryptography, 8.4.0"
#:package Indice.Cryptography@8.4.0
#addin nuget:?package=Indice.Cryptography&version=8.4.0Install as a Cake Addin
#tool nuget:?package=Indice.Cryptography&version=8.4.0Install as a Cake Tool
A comprehensive .NET cryptography library focused on PSD2 compliance, X.509 certificate management, and HTTP message signing.
Install the package via NuGet Package Manager:
Install-Package Indice.Cryptography
Or via .NET CLI:
dotnet add package Indice.Cryptography
using Indice.Cryptography;
using Indice.Cryptography.X509Certificates;
var certificateManager = new CertificateManager();
// Create a PSD2 certificate request
var request = new Psd2CertificateRequest
{
City = "Athens",
State = "Attiki",
CountryCode = "GR",
Organization = "Example Bank",
OrganizationUnit = "IT",
CommonName = "api.example-bank.com",
AuthorityId = "BOG",
AuthorityName = "Bank of Greece",
AuthorizationNumber = "123456789",
ValidityInDays = 365,
Roles = new Psd2CertificateRequest.Psd2RoleFlags
{
Aisp = true, // Account Information Service Provider
Pisp = true, // Payment Initiation Service Provider
Aspsp = true, // Account Servicing Payment Service Provider
Piisp = false // Payment Instrument Issuer Service Provider
},
QcType = QcTypeIdentifiers.Web
};
// Generate the certificate
var certificate = certificateManager.CreateQualifiedCertificate(
request,
"ca.example.com",
issuer: null, // Will create CA on-the-fly
out RSA privateKey
);
using Indice.Cryptography.Tokens.HttpMessageSigning;
// Configure HTTP signatures
services.AddHttpSignatures(options => {
options.MapPath("/payments",
HeaderFieldNames.RequestTarget,
HeaderFieldNames.Created,
HttpDigest.HTTPHeaderName,
"x-response-id");
})
.AddSigningCredential(certificate);
// Use in your application
app.UseHttpSignatures();
using Indice.Cryptography.Validation;
var validator = new Psd2ClientCertificateValidator();
var isValid = await validator.ValidateAsync(certificate, context);
The library includes comprehensive support for European Qualified Certificate extensions:
// In Program.cs or Startup.cs
services.AddCertificateServer(environment, options => {
options.IssuerDomain = "ca.example.com";
options.AddEntityFrameworkStore(sqlOptions => {
sqlOptions.ConfigureDbContext = builder => {
builder.UseSqlServer(connectionString);
};
});
});
// Configure HTTP signatures for specific endpoints
services.AddHttpSignatures(options => {
options.MapPath("/api/payments/*",
HeaderFieldNames.RequestTarget,
HeaderFieldNames.Created,
HttpDigest.HTTPHeaderName);
})
.AddSigningCredential(certificate);
var certificateManager = new CertificateManager();
// Create a root CA certificate
var rootCA = certificateManager.CreateRootCACertificate(
"Root CA Example",
diagnostics: null
);
// Use the CA to sign other certificates
var clientCertificate = certificateManager.CreateQualifiedCertificate(
request,
issuerDomain: "ca.example.com",
issuer: rootCA,
out RSA privateKey
);
var qcStatements = new QualifiedCertificateStatementsExtension(
isCompliant: true,
limit: new QcMonetaryValue { CurrencyCode = "EUR", Value = 500000 },
retentionPeriod: 7,
isQSCD: true,
pdsLocations: new[] {
new PdsLocation {
Language = "EN",
Url = "https://example.com/pds"
}
},
type: QcTypeIdentifiers.Web,
psd2: new Psd2Attributes
{
AuthorityName = "National Bank",
AuthorizationId = new NCAId("PSD", "GR", "NBG", "123456"),
HasAccountInformation = true,
HasPaymentInitiation = true
},
critical: false
);
var authorityInfo = new AuthorityInformationAccessExtension(new[] {
new AccessDescription
{
AccessMethod = AccessDescription.AccessMethodType.CertificationAuthorityIssuer,
AccessLocation = "http://ca.example.com/ca.cer"
},
new AccessDescription
{
AccessMethod = AccessDescription.AccessMethodType.OnlineCertificateStatusProtocol,
AccessLocation = "http://ocsp.example.com"
}
}, critical: false);
The library supports all PSD2 payment service provider roles:
| Role Code | Description | Property |
|---|---|---|
| PSP_AS | Account Servicing | HasAccountServicing |
| PSP_PI | Payment Initiation | HasPaymentInitiation |
| PSP_AI | Account Information | HasAccountInformation |
| PSP_IC | Payment Instrument Issuing | HasIssuingOfCardBasedPaymentInstruments |
The library implements the HTTP Signatures draft specification for securing HTTP messages:
// Signature string format
var signatureString = $"{HeaderFieldNames.RequestTarget}: post /payments\n" +
$"{HeaderFieldNames.Created}: 1618302811\n" +
$"{HttpDigest.HTTPHeaderName}: SHA-256=X48E9qOokqqrvdts8nOJRJN3OWDUoyWxBf7kbu9DBPE=";
// Generate signature
var signature = HttpSignature.GenerateSignature(signatureString, privateKey);
var subject = new SubjectBuilder()
.AddCommonName("api.bank.com")
.AddOrganization("Example Bank", "IT Department")
.AddLocation("GR", "Attiki", "Athens")
.AddEmail("admin@bank.com")
.AddOrganizationIdentifier(new NCAId("PSD", "GR", "BOG", "123456"))
.Build();
var crlExtension = new CRLDistributionPointsExtension(new[] {
new CRLDistributionPoint
{
FullName = new[] { "http://crl.example.com/revoked.crl" }
}
}, critical: false);
This library implements the following standards:
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the terms specified in the project license file (MIT).
For questions and support, please check the project's issue tracker or contact the maintainers.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 net8.0 is compatible. net8.0-android net8.0-android was computed. net8.0-browser net8.0-browser was computed. net8.0-ios net8.0-ios was computed. net8.0-maccatalyst net8.0-maccatalyst was computed. net8.0-macos net8.0-macos was computed. net8.0-tvos net8.0-tvos was computed. net8.0-windows net8.0-windows was computed. net9.0 net9.0 is compatible. net9.0-android net9.0-android was computed. net9.0-browser net9.0-browser was computed. net9.0-ios net9.0-ios was computed. net9.0-maccatalyst net9.0-maccatalyst was computed. net9.0-macos net9.0-macos was computed. net9.0-tvos net9.0-tvos was computed. net9.0-windows net9.0-windows was computed. net10.0 net10.0 is compatible. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
Showing the top 2 NuGet packages that depend on Indice.Cryptography:
| Package | Downloads |
|---|---|
|
Indice.Cryptography.AspNetCore
Package Description |
|
|
Indice.IdentityServer.Psd2
Package Description |
This package is not used by any popular GitHub repositories.
Expose header name.