Skip to content

Commit eba1370

Browse files
author
Lee Fine
committed
1 parent 3aee96d commit eba1370

File tree

1 file changed

+17
-8
lines changed

1 file changed

+17
-8
lines changed

RemoteFile/ManagementBase.cs

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
using Org.BouncyCastle.X509;
1616
using System;
1717
using System.IO;
18+
using System.Linq.Expressions;
1819
using static Org.BouncyCastle.Math.EC.ECCurve;
1920

2021
namespace Keyfactor.Extensions.Orchestrator.RemoteFile
@@ -126,17 +127,25 @@ private string GetThumbprint (ManagementJobCertificate jobCertificate, ILogger l
126127

127128
string thumbprint = string.Empty;
128129

129-
using (MemoryStream ms = new MemoryStream(Convert.FromBase64String(jobCertificate.Contents)))
130+
if (string.IsNullOrEmpty(jobCertificate.PrivateKeyPassword))
130131
{
131-
Pkcs12StoreBuilder storeBuilder = new Pkcs12StoreBuilder();
132-
Pkcs12Store store = storeBuilder.Build();
132+
X509Certificate x = new X509Certificate(Convert.FromBase64String(jobCertificate.Contents));
133+
thumbprint = x.Thumbprint();
134+
}
135+
else
136+
{
137+
using (MemoryStream ms = new MemoryStream(Convert.FromBase64String(jobCertificate.Contents)))
138+
{
139+
Pkcs12StoreBuilder storeBuilder = new Pkcs12StoreBuilder();
140+
Pkcs12Store store = storeBuilder.Build();
133141

134-
store.Load(ms, jobCertificate.PrivateKeyPassword.ToCharArray());
142+
store.Load(ms, jobCertificate.PrivateKeyPassword.ToCharArray());
135143

136-
foreach (string alias in store.Aliases)
137-
{
138-
thumbprint = store.GetCertificate(alias).Certificate.Thumbprint();
139-
break;
144+
foreach (string alias in store.Aliases)
145+
{
146+
thumbprint = store.GetCertificate(alias).Certificate.Thumbprint();
147+
break;
148+
}
140149
}
141150
}
142151

0 commit comments

Comments
 (0)