Skip to content

Commit 8e12e47

Browse files
committed
logging
1 parent d2a103a commit 8e12e47

1 file changed

Lines changed: 17 additions & 1 deletion

File tree

sectigo-scm-caplugin/Client/SectigoClient.cs

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ public async Task CertificateListProducer(BlockingCollection<Certificate> certs,
135135

136136
public async Task<List<Certificate>> PageCertificates(int position = 0, int size = 25, string filter = "")
137137
{
138-
string filterQueryString = String.IsNullOrEmpty(filter) ? string.Empty : $"&{filter}";
138+
string filterQueryString = string.IsNullOrEmpty(filter) ? string.Empty : $"&{filter}";
139139
Logger.LogTrace($"API Request: api/ssl/v1?position={position}&size={size}{filterQueryString}".TrimEnd());
140140
var response = await RestClient.GetAsync($"api/ssl/v1?position={position}&size={size}{filterQueryString}".TrimEnd());
141141
return await ProcessResponse<List<Certificate>>(response);
@@ -322,6 +322,22 @@ public static SectigoClient InitializeClient(SectigoConfig config, ICertificateR
322322
throw new Exception("AuthType set to Certificate, but no certificate found!");
323323
}
324324

325+
Logger.LogDebug($"CERT DETAILS: \nSerial Number: {authCert.GetSerialNumberString}\nHas PK: {authCert.HasPrivateKey.ToString()}\nSubject: {authCert.Subject}");
326+
327+
Logger.LogTrace("Checking for private key permissions.");
328+
try
329+
{
330+
//https://www.pkisolutions.com/accessing-and-using-certificate-private-keys-in-net-framework-net-core/
331+
_ = authCert.GetRSAPrivateKey();
332+
_ = authCert.GetDSAPrivateKey();
333+
_ = authCert.GetECDsaPrivateKey();
334+
}
335+
catch
336+
{
337+
throw new Exception("Unable to access the authentication certificate's private key.");
338+
}
339+
340+
325341
clientHandler.ClientCertificates.Add(authCert);
326342
}
327343

0 commit comments

Comments
 (0)