From 37601ffd735f72d616ec1b47f88ac0e8709be9a3 Mon Sep 17 00:00:00 2001 From: Nick Genovese Date: Tue, 5 Nov 2024 10:15:03 -0500 Subject: [PATCH] feat: replaced deprecated Bouncy Castle - replaced with BouncyCastle.Cryptography --- src/Pepperdash.Core/PepperDash.Core.csproj | 2 +- src/Pepperdash.Core/Web/BouncyCertificate.cs | 9 +-------- 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/src/Pepperdash.Core/PepperDash.Core.csproj b/src/Pepperdash.Core/PepperDash.Core.csproj index 88772d8..2c4b19d 100644 --- a/src/Pepperdash.Core/PepperDash.Core.csproj +++ b/src/Pepperdash.Core/PepperDash.Core.csproj @@ -29,6 +29,7 @@ + @@ -39,7 +40,6 @@ - all diff --git a/src/Pepperdash.Core/Web/BouncyCertificate.cs b/src/Pepperdash.Core/Web/BouncyCertificate.cs index 8468c23..e5262fa 100644 --- a/src/Pepperdash.Core/Web/BouncyCertificate.cs +++ b/src/Pepperdash.Core/Web/BouncyCertificate.cs @@ -1,6 +1,4 @@ using Crestron.SimplSharp; - -#if NET472 using System; using System.Collections.Generic; using System.IO; @@ -10,7 +8,6 @@ using Org.BouncyCastle.Asn1.X509; using Org.BouncyCastle.Crypto; using Org.BouncyCastle.Crypto.Generators; using Org.BouncyCastle.Crypto.Prng; -using Org.BouncyCastle.Math; using Org.BouncyCastle.Pkcs; using Org.BouncyCastle.Security; using Org.BouncyCastle.Utilities; @@ -18,10 +15,7 @@ using Org.BouncyCastle.X509; using X509Certificate2 = System.Security.Cryptography.X509Certificates.X509Certificate2; using X509KeyStorageFlags = System.Security.Cryptography.X509Certificates.X509KeyStorageFlags; using X509ContentType = System.Security.Cryptography.X509Certificates.X509ContentType; -using System.Text; using Org.BouncyCastle.Crypto.Operators; -using System.Numerics; -using System.Security.Cryptography.X509Certificates; using BigInteger = Org.BouncyCastle.Math.BigInteger; using X509Certificate = Org.BouncyCastle.X509.X509Certificate; @@ -285,7 +279,7 @@ namespace PepperDash.Core // Now to convert the Bouncy Castle certificate to a .NET certificate. // See http://web.archive.org/web/20100504192226/http://www.fkollmann.de/v2/post/Creating-certificates-using-BouncyCastle.aspx // ...but, basically, we create a PKCS12 store (a .PFX file) in memory, and add the public and private key to that. - var store = new Pkcs12Store(); + var store = new Pkcs12StoreBuilder().Build(); // What Bouncy Castle calls "alias" is the same as what Windows terms the "friendly name". string friendlyName = certificate.SubjectDN.ToString(); @@ -359,4 +353,3 @@ namespace PepperDash.Core } } } -#endif