Skip to content

Commit 767577c

Browse files
saintentropyQilongTang
authored andcommitted
Change mechanism to retreive the certificate from assembly (DynamoDS#10301)
1 parent 3a0b3e3 commit 767577c

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/DynamoUtilities/CertificateVerification.cs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using System.IO;
44
using System.Linq;
55
using System.Reflection;
6+
using System.Security.Cryptography.X509Certificates;
67
using System.Text;
78
using System.Threading.Tasks;
89

@@ -37,7 +38,17 @@ public static bool CheckAssemblyForValidCertificate(string assemblyPath)
3738
}
3839

3940
//Verify the node library has a verified signed certificate
40-
var cert = asm.Modules.FirstOrDefault()?.GetSignerCertificate();
41+
X509Certificate cert;
42+
try
43+
{
44+
cert = X509Certificate.CreateFromSignedFile(assemblyPath);
45+
}
46+
catch
47+
{
48+
throw new Exception(String.Format(
49+
"A dll file found at {0} did not have a certificate attached.", assemblyPath));
50+
}
51+
4152
if (cert != null)
4253
{
4354
var cert2 = new System.Security.Cryptography.X509Certificates.X509Certificate2(cert);

0 commit comments

Comments
 (0)