Skip to content

Commit 4a29385

Browse files
author
Bob Pokorny
committed
Testing SSH on Linux
1 parent 10f0a49 commit 4a29385

File tree

5 files changed

+252
-44
lines changed

5 files changed

+252
-44
lines changed

IISU/ClientPSCertStoreReEnrollment.cs

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,27 @@ public JobResult PerformReEnrollment(ReenrollmentJobConfiguration config, Submit
8989
using (_psHelper)
9090
{
9191
// First create and return the CSR
92-
var csr = CreateCSR(subjectText, providerName, keyType, keySize, SAN);
92+
_logger.LogTrace($"Subject Text: {subjectText}");
93+
_logger.LogTrace($"Provider Name: {providerName}");
94+
_logger.LogTrace($"Key Type: {keyType}");
95+
_logger.LogTrace($"Key Size: {keySize}");
96+
_logger.LogTrace($"SAN: {SAN}");
97+
98+
string csr = string.Empty;
99+
100+
try
101+
{
102+
_logger.LogTrace("Attempting to Create CSR");
103+
csr = CreateCSR(subjectText, providerName, keyType, keySize, SAN);
104+
_logger.LogTrace("Returned from creating CSR");
105+
}
106+
catch (Exception ex)
107+
{
108+
_logger.LogError($"Error while attempting to create the CSR: {ex.Message}");
109+
throw new Exception("Unable to create the CSR file. Check the Orchestrator Logs for more information");
110+
}
111+
112+
_logger.LogTrace($"CSR Contents: '{csr}'");
93113

94114
if (csr != string.Empty)
95115
{
@@ -158,10 +178,12 @@ public JobResult PerformReEnrollment(ReenrollmentJobConfiguration config, Submit
158178
};
159179
}
160180
finally
161-
{
162-
_psHelper.Terminate();
181+
{
182+
if (_psHelper != null)
183+
{
184+
_psHelper.Terminate();
185+
}
163186
}
164-
165187
}
166188

167189
private string CreateCSR(string subjectText, string providerName, string keyType, int keySize, string SAN)
@@ -183,9 +205,9 @@ private string CreateCSR(string subjectText, string providerName, string keyType
183205
{ "keyLength", keySize },
184206
{ "SAN", SAN }
185207
};
186-
_logger.LogTrace("Attempting to execute PS function (New-CsrEnrollment)");
208+
_logger.LogInformation("Attempting to execute PS function (New-CsrEnrollment)");
187209
_results = _psHelper.ExecutePowerShell("New-CsrEnrollment", parameters);
188-
_logger.LogTrace("Returned from executing PS function (New-CsrEnrollment)");
210+
_logger.LogInformation("Returned from executing PS function (New-CsrEnrollment)");
189211

190212
// This should return the CSR that was generated
191213
if (_results == null || _results.Count == 0)

IISU/ImplementedStoreTypes/Win/Inventory.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ public List<CurrentInventoryItem> QueryWinCertCertificates(RemoteSettings settin
128128
{
129129
{ "StoreName", StoreName }
130130
};
131-
131+
132132
results = ps.ExecutePowerShell("Get-KFCertificates", parameters);
133133

134134
// If there are certificates, deserialize the results and send them back to command
@@ -148,7 +148,7 @@ public List<CurrentInventoryItem> QueryWinCertCertificates(RemoteSettings settin
148148
Inventory.Add(
149149
new CurrentInventoryItem
150150
{
151-
Certificates = new[] { cert.Base64Data},
151+
Certificates = new[] { cert.Base64Data },
152152
Alias = cert.Thumbprint,
153153
PrivateKeyEntry = cert.HasPrivateKey,
154154
UseChainLevel = false,

IISU/ImplementedStoreTypes/Win/Management.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
using System.Collections.ObjectModel;
2626
using System.Collections.Generic;
2727
using System.Management.Automation.Runspaces;
28+
using System.Security.Cryptography.X509Certificates;
2829

2930
namespace Keyfactor.Extensions.Orchestrator.WindowsCertStore.WinCert
3031
{
@@ -153,7 +154,7 @@ public JobResult AddCertificate(string certificateContents, string privateKeyPas
153154
if (!string.IsNullOrEmpty(privateKeyPassword)) { parameters.Add("PrivateKeyPassword", privateKeyPassword); }
154155
if (!string.IsNullOrEmpty(cryptoProvider)) { parameters.Add("CryptoServiceProvider", cryptoProvider); }
155156

156-
_results = _psHelper.ExecutePowerShell("Add-KFCertificateToStore", parameters);
157+
_results = _psHelper.ExecutePowerShell("Add-KFCertificateToStore ", parameters);
157158
_logger.LogTrace("Returned from executing PS function (Add-KFCertificateToStore)");
158159

159160
// This should return the thumbprint of the certificate

0 commit comments

Comments
 (0)