From 5332d5fe1a0cd0882c244eb37e4ecca7aaa15b2d Mon Sep 17 00:00:00 2001 From: Kei-Luna Date: Wed, 13 May 2026 07:39:42 +0900 Subject: [PATCH] Change certificate generation --- SdkServer/Utils/CertHelper.cs | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/SdkServer/Utils/CertHelper.cs b/SdkServer/Utils/CertHelper.cs index 6666cea..f6f52d4 100644 --- a/SdkServer/Utils/CertHelper.cs +++ b/SdkServer/Utils/CertHelper.cs @@ -48,19 +48,7 @@ public static class CertHelper private static X509Certificate2 CreateSelfSigned(string host) { - // CNG key must have AllowPlainTextExport so the private key is included in PFX export. - // Without this, Export(Pfx) produces a cert-only PFX, and EphemeralKeySet loads a - // keyless cert that Kestrel cannot use for TLS. - var cngParams = new CngKeyCreationParameters - { - ExportPolicy = CngExportPolicies.AllowPlaintextExport, - KeyUsage = CngKeyUsages.AllUsages - }; - cngParams.Parameters.Add(new CngProperty("Length", - BitConverter.GetBytes(2048), CngPropertyOptions.None)); - - using var cngKey = CngKey.Create(CngAlgorithm.Rsa, null, cngParams); - using var rsa = new RSACng(cngKey); + using var rsa = RSA.Create(2048); var req = new CertificateRequest( new X500DistinguishedName($"CN={host}"), @@ -84,7 +72,6 @@ public static class CertHelper DateTimeOffset.UtcNow.AddHours(-1), DateTimeOffset.UtcNow.AddYears(10)); - // Private key is now exportable — PFX includes key material var pfx = cert.Export(X509ContentType.Pfx, Password); return LoadPkcs12(pfx); }