====== TrustStoreExtensions & PqTrustStore ======
Gestione Trust Store personalizzato per infrastrutture PKI compatibili con PQ.
----
===== Panoramica =====
^ Classe ^ Descrizione ^
| ''PqTrustStore'' | Trust Store completo con supporto PQ |
| ''TrustStoreExtensions'' | Extension Methods per ''X509Certificate2Collection'' |
| ''TrustEntry'' | Metadati per voci del Trust Store |
----
===== Classe PqTrustStore =====
using WvdS.System.Security.Cryptography.X509Certificates;
// Creare Trust Store
using var trustStore = new PqTrustStore();
// Aggiungere Root CA
var rootCa = new X509Certificate2("root-ca.cer");
trustStore.AddTrustAnchor(rootCa, alias: "Company Root CA");
// Aggiungere Intermediate CA
var intermediateCa = new X509Certificate2("intermediate-ca.cer");
trustStore.AddIntermediate(intermediateCa, alias: "Issuing CA");
----
===== Integrazione con X509Chain =====
// Caricare Trust Store
using var trustStore = PqTrustStore.LoadFromPem("company-trust-store.pem");
// Validare certificato
var userCert = new X509Certificate2("user.cer");
using var chain = new X509Chain();
bool isValid = chain.Build(userCert, trustStore, CryptoMode.Hybrid);
----
===== Import/Export Trust Store =====
// Salvare/caricare bundle PEM
trustStore.SaveToPem("trust-store.pem");
var loadedStore = PqTrustStore.LoadFromPem("trust-store.pem");
// PKCS#7 (DER)
trustStore.SaveToPkcs7("trust-store.p7b");
var p7Store = PqTrustStore.LoadFromPkcs7("trust-store.p7b");
----
===== Import da System Store =====
using var trustStore = new PqTrustStore();
// Importare Root CA di Windows
trustStore.ImportFromSystemRootStore();
// Esportare come PEM per sistemi air-gapped
trustStore.SaveToPem("system-trust-store.pem");
----
===== Enum TrustType =====
^ Valore ^ Descrizione ^
| ''TrustAnchor'' | Ancora di fiducia (Root CA) |
| ''IntermediateCA'' | Autorita di certificazione intermedia |
| ''CrossCertifiedCA'' | CA con certificazione incrociata |
| ''EndEntity'' | End-Entity (non CA) |
----
===== Query Trust Store =====
// Solo Trust Anchor
var roots = trustStore.TrustAnchors;
// Solo Intermediate CA
var intermediates = trustStore.IntermediateCAs;
// Ricerca per Subject/Thumbprint
var found = trustStore.FindBySubjectName("Company");
var entry = trustStore.FindByThumbprint("A1B2C3...");
----
===== Vedi anche =====
* [[.:x509chainextensions|X509ChainExtensions]]
* [[.:revocationextensions|RevocationExtensions]]
----
//Wolfgang van der Stille @ EMSR DATA d.o.o. - Post-Quantum Cryptography Professional//
{{tag>truststore pki ca chain}}