Scenario 12.4: Interoperabilita
Categoria: Import/Export
Complessita: ⭐⭐⭐⭐ (Alta)
Prerequisiti: Vari sistemi/piattaforme
Tempo stimato: 30-45 minuti
Descrizione
Questo scenario descrive l'interoperabilita cross-platform di certificati e chiavi. Con la crittografia PQ e necessaria particolare attenzione poiche non tutti i sistemi supportano ancora ML-DSA/ML-KEM.
Sfide di interoperabilita:
- Differenze di formato - PEM vs. DER vs. PFX
- Supporto algoritmi - Classico vs. PQ vs. Ibrido
- Particolarita piattaforma - Windows, Linux, macOS, Java
- Differenze di versione - OpenSSL 1.x vs. 3.x
Matrice di compatibilita
| Sistema | RSA | ECDSA | ML-DSA | ML-KEM | Ibrido |
|---|---|---|---|---|---|
| OpenSSL 3.6+ | ✅ | ✅ | ✅ | ✅ | ✅ |
| OpenSSL 3.0-3.5 | ✅ | ✅ | ❌ | ❌ | ❌ |
| .NET 9+ | ✅ | ✅ | ✅ | ✅ | ✅ |
| Java 21+ | ✅ | ✅ | 🟡 (Bouncy Castle) | 🟡 | ❌ |
| Windows SChannel | ✅ | ✅ | ❌ | ❌ | ❌ |
| macOS Security | ✅ | ✅ | ❌ | ❌ | ❌ |
| Firefox/NSS | ✅ | ✅ | ❌ | 🟡 | ❌ |
| Chrome/BoringSSL | ✅ | ✅ | ❌ | 🟡 | ❌ |
🟡 = Supporto sperimentale/Preview
Code-Esempio: Conversione formato
using WvdS.Security.Cryptography.X509Certificates.Extensions.PQ; public class CertificateConverter { public byte[] ConvertFormat( byte[] sourceData, CertificateFormat sourceFormat, CertificateFormat targetFormat, string password = null) { // 1. Caricare in oggetto .NET var cert = LoadCertificate(sourceData, sourceFormat, password); // 2. Esportare nel formato destinazione return ExportCertificate(cert, targetFormat, password); } private X509Certificate2 LoadCertificate( byte[] data, CertificateFormat format, string password) { return format switch { CertificateFormat.Der => new X509Certificate2(data), CertificateFormat.Pem => X509Certificate2.CreateFromPem(Encoding.UTF8.GetString(data)), CertificateFormat.Pfx => new X509Certificate2(data, password, X509KeyStorageFlags.Exportable), _ => throw new NotSupportedException($"Formato {format} non supportato") }; } private byte[] ExportCertificate( X509Certificate2 cert, CertificateFormat format, string password) { return format switch { CertificateFormat.Der => cert.RawData, CertificateFormat.Pem => Encoding.UTF8.GetBytes(cert.ExportCertificatePem()), CertificateFormat.Pfx => cert.Export(X509ContentType.Pfx, password), _ => throw new NotSupportedException($"Formato {format} non supportato") }; } } public enum CertificateFormat { Der, Pem, Pfx, P7b }
Code-Esempio: Fallback certificato ibrido
public class HybridCertificateFallback { public X509Certificate2 GetCompatibleCertificate( X509Certificate2 hybridCert, PlatformCapabilities targetCapabilities) { using var ctx = PqCryptoContext.Initialize(); // Verificare se certificato ibrido var algorithm = hybridCert.GetKeyAlgorithm(); if (!IsHybridAlgorithm(algorithm)) { // Non ibrido - restituire direttamente return hybridCert; } // Destinazione supporta PQ? if (targetCapabilities.SupportsPqAlgorithms) { return hybridCert; } // Fallback: estrarre parte classica Console.WriteLine("Destinazione non supporta PQ - uso fallback classico"); // Caricare catena certificati alternativa (se disponibile) var classicalCert = FindClassicalAlternative(hybridCert); if (classicalCert != null) { return classicalCert; } throw new NotSupportedException( "Sistema destinazione non supporta PQ e nessun fallback classico disponibile" ); } private bool IsHybridAlgorithm(string algorithm) { return algorithm.Contains("ML-DSA") || algorithm.Contains("ML-KEM") || algorithm.Contains("DILITHIUM") || algorithm.Contains("KYBER"); } private X509Certificate2 FindClassicalAlternative(X509Certificate2 hybridCert) { // Cercare certificato con stesso Subject ma algoritmo classico using var store = new X509Store(StoreName.My, StoreLocation.CurrentUser); store.Open(OpenFlags.ReadOnly); var alternatives = store.Certificates .Find(X509FindType.FindBySubjectDistinguishedName, hybridCert.Subject, validOnly: true) .Where(c => !IsHybridAlgorithm(c.GetKeyAlgorithm())) .OrderByDescending(c => c.NotAfter) .FirstOrDefault(); return alternatives; } } public class PlatformCapabilities { public bool SupportsPqAlgorithms { get; set; } public bool SupportsTls13 { get; set; } public static PlatformCapabilities Detect() { return new PlatformCapabilities { SupportsPqAlgorithms = CheckPqSupport(), SupportsTls13 = CheckTls13Support() }; } private static bool CheckPqSupport() { try { // Verificare se OpenSSL 3.6+ con provider PQ disponibile return OpenSslInterop.IsOpenSsl36OrNewer(); } catch { return false; } } private static bool CheckTls13Support() { return Environment.OSVersion.Platform == PlatformID.Win32NT ? Environment.OSVersion.Version >= new Version(10, 0, 17763) : true; } }
Interoperabilita specifica per settore
| Settore | Piattaforme principali | Formato | Particolarita |
|---|---|---|---|
| Banking | Java + .NET | JKS, PFX | Compliance FIPS |
| Healthcare | Windows + Linux | PFX, PEM | Integrazione HL7/FHIR |
| IoT | Embedded Linux | DER | Risorse limitate |
| Cloud | Multi-Platform | PEM | Container/Kubernetes |
Scenari correlati
| Relazione | Scenario | Descrizione |
|---|---|---|
| Base | 12.1 PEM Export | Formato Linux |
| Base | 12.2 PFX Export | Formato Windows |
| Correlato | 10.4 TLS ibrido | Compatibilita PQ-TLS |
| Correlato | Algoritmi | Fondamenti PQ |
« ← 12.3 PKCS#7 Chain | ↑ Import/Export | → Tutti gli scenari »
Wolfgang van der Stille @ EMSR DATA d.o.o. - Post-Quantum Cryptography Professional
Zuletzt geändert: il 30/01/2026 alle 00:22