From 88eff5749e13b7ad1891d850603147a66dcd2a74 Mon Sep 17 00:00:00 2001 From: Craig Long Date: Thu, 16 Jan 2020 15:19:07 -0500 Subject: [PATCH] Change mechanism to retreive the certificate from assembly (#10301) (#10303) (cherry picked from commit 767577c6c0de187b64fc3dda3ff012f16c008208) --- src/DynamoUtilities/CertificateVerification.cs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/DynamoUtilities/CertificateVerification.cs b/src/DynamoUtilities/CertificateVerification.cs index 9695329c4aa..2971a4318ea 100644 --- a/src/DynamoUtilities/CertificateVerification.cs +++ b/src/DynamoUtilities/CertificateVerification.cs @@ -3,6 +3,7 @@ using System.IO; using System.Linq; using System.Reflection; +using System.Security.Cryptography.X509Certificates; using System.Text; using System.Threading.Tasks; @@ -37,7 +38,17 @@ public static bool CheckAssemblyForValidCertificate(string assemblyPath) } //Verify the node library has a verified signed certificate - var cert = asm.Modules.FirstOrDefault()?.GetSignerCertificate(); + X509Certificate cert; + try + { + cert = X509Certificate.CreateFromSignedFile(assemblyPath); + } + catch + { + throw new Exception(String.Format( + "A dll file found at {0} did not have a certificate attached.", assemblyPath)); + } + if (cert != null) { var cert2 = new System.Security.Cryptography.X509Certificates.X509Certificate2(cert);