Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 18 additions & 2 deletions .github/workflows/keyfactor-starter-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,26 @@ jobs:
call-create-github-release-workflow:
uses: Keyfactor/actions/.github/workflows/github-release.yml@main

get-manifest-properties:
runs-on: windows-latest
outputs:
update_catalog: ${{ steps.read-json.outputs.prop }}
steps:
- uses: actions/checkout@v3
- name: Read json
id: read-json
shell: pwsh
run: |
$json = Get-Content integration-manifest.json | ConvertFrom-Json
echo "::set-output name=prop::$(echo $json.update_catalog)"

call-dotnet-build-and-release-workflow:
needs: [call-create-github-release-workflow]
uses: Keyfactor/actions/.github/workflows/dotnet-build-and-release.yml@main
with:
release_version: ${{ needs.call-create-github-release-workflow.outputs.release_version }}
release_url: ${{ needs.call-create-github-release-workflow.outputs.release_url }}
release_dir: IISU/bin/Release/netcoreapp3.1
release_dir: IISU/bin/Release/netcoreapp3.1
secrets:
token: ${{ secrets.PRIVATE_PACKAGE_ACCESS }}

Expand All @@ -22,7 +35,10 @@ jobs:
token: ${{ secrets.APPROVE_README_PUSH }}

call-update-catalog-workflow:
if: github.event_name == 'push' || github.event_name == 'workflow_dispatch'
needs: get-manifest-properties
if: needs.get-manifest-properties.outputs.update_catalog == 'True' && (github.event_name == 'push' || github.event_name == 'workflow_dispatch')
uses: Keyfactor/actions/.github/workflows/update-catalog.yml@main
secrets:
token: ${{ secrets.SDK_SYNC_PAT }}


6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
2.0.1
2.1.0
* Fixed issue that was occuring during renewal when there were bindings outside of http and https like net.tcp
* Added PAM registration/initialization documentation in README.md
* Resolved Null HostName error
* Added WinCert Cert Store Type
* Added custom property parser to not show any passwords
* Removed any password references in trace logs and output settings in JSON format

2.0.0
* Add support for reenrollment jobs (On Device Key Generation) with the ability to specify a cryptographic provider. Specification of cryptographic provider allows HSM (Hardware Security Module) use.
Expand Down
1 change: 1 addition & 0 deletions IISU/ClientPSCertStoreManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ function InstallPfxToMachineStore([byte[]]$bytes, [string]$password, [string]$st
$certStore.Open(5)
$cert = New-Object -TypeName System.Security.Cryptography.X509Certificates.X509Certificate2 -ArgumentList $bytes, $password, 18 <# Persist, Machine #>
$certStore.Add($cert)

$certStore.Close();
}";

Expand Down
13 changes: 7 additions & 6 deletions IISU/ClientPSCertStoreReEnrollment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
// See the License for the specific language governing permissions and
// limitations under the License.

using Keyfactor.Extensions.Orchestrator.WindowsCertStore.WinIIS;
using Keyfactor.Logging;
using Keyfactor.Orchestrators.Common.Enums;
using Keyfactor.Orchestrators.Extensions;
Expand All @@ -34,8 +33,8 @@ namespace Keyfactor.Extensions.Orchestrator.WindowsCertStore
{
internal class ClientPSCertStoreReEnrollment
{
private ILogger _logger;
private IPAMSecretResolver _resolver;
private readonly ILogger _logger;
private readonly IPAMSecretResolver _resolver;

public ClientPSCertStoreReEnrollment(ILogger logger, IPAMSecretResolver resolver)
{
Expand All @@ -59,8 +58,10 @@ public JobResult PerformReEnrollment(ReenrollmentJobConfiguration config, Submit
JobProperties properties = JsonConvert.DeserializeObject<JobProperties>(config.CertificateStoreDetails.Properties,
new JsonSerializerSettings { DefaultValueHandling = DefaultValueHandling.Populate });

WSManConnectionInfo connectionInfo = new WSManConnectionInfo(new Uri($"{properties?.WinRmProtocol}://{config.CertificateStoreDetails.ClientMachine}:{properties?.WinRmPort}/wsman"));
connectionInfo.IncludePortInSPN = properties.SpnPortFlag;
WSManConnectionInfo connectionInfo = new WSManConnectionInfo(new Uri($"{properties?.WinRmProtocol}://{config.CertificateStoreDetails.ClientMachine}:{properties?.WinRmPort}/wsman"))
{
IncludePortInSPN = properties.SpnPortFlag
};
var pw = new NetworkCredential(serverUserName, serverPassword).SecurePassword;
_logger.LogTrace($"Credentials: UserName:{serverUserName}");

Expand Down Expand Up @@ -91,7 +92,7 @@ public JobResult PerformReEnrollment(ReenrollmentJobConfiguration config, Submit
Collection<PSObject> results;

// If the provider name is null, default it to the Microsoft CA
if (providerName == null) providerName = "Microsoft Strong Cryptographic Provider";
providerName ??= "Microsoft Strong Cryptographic Provider";

// Create the script file
ps.AddScript("$infFilename = New-TemporaryFile");
Expand Down
8 changes: 4 additions & 4 deletions IISU/ClientPSIIManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ internal class ClientPSIIManager

private long JobHistoryID { get; set; }

private ILogger _logger;
private Runspace _runSpace;
private readonly ILogger _logger;
private readonly Runspace _runSpace;

private PowerShell ps;

Expand Down Expand Up @@ -82,7 +82,7 @@ public ClientPSIIManager(ReenrollmentJobConfiguration config, string serverUsern
Port = config.JobProperties["Port"].ToString();
HostName = config.JobProperties["HostName"]?.ToString();
Protocol = config.JobProperties["Protocol"].ToString();
SniFlag = config.JobProperties["SniFlag"].ToString()?.Substring(0, 1);
SniFlag = config.JobProperties["SniFlag"]?.ToString()[..1];
IPAddress = config.JobProperties["IPAddress"].ToString();

PrivateKeyPassword = ""; // A reenrollment does not have a PFX Password
Expand Down Expand Up @@ -119,7 +119,7 @@ public ClientPSIIManager(ManagementJobConfiguration config, string serverUsernam
Port = config.JobProperties["Port"].ToString();
HostName = config.JobProperties["HostName"]?.ToString();
Protocol = config.JobProperties["Protocol"].ToString();
SniFlag = config.JobProperties["SniFlag"].ToString()?.Substring(0, 1);
SniFlag = config.JobProperties["SniFlag"].ToString()?[..1];
IPAddress = config.JobProperties["IPAddress"].ToString();

PrivateKeyPassword = ""; // A reenrollment does not have a PFX Password
Expand Down
4 changes: 2 additions & 2 deletions IISU/ImplementedStoreTypes/Win/Inventory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
using Microsoft.Extensions.Logging;
using Newtonsoft.Json;

namespace Keyfactor.Extensions.Orchestrator.WindowsCertStore.Win
namespace Keyfactor.Extensions.Orchestrator.WindowsCertStore.WinCert
{
public class Inventory : WinCertJobTypeBase, IInventoryJobExtension
{
Expand Down Expand Up @@ -55,7 +55,7 @@ private JobResult PerformInventory(InventoryJobConfiguration config, SubmitInven
{
var inventoryItems = new List<CurrentInventoryItem>();

_logger.LogTrace($"Job Configuration: {JsonConvert.SerializeObject(config)}");
_logger.LogTrace(JobConfigurationParser.ParseInventoryJobConfiguration(config));

string serverUserName = PAMUtilities.ResolvePAMField(_resolver, _logger, "Server UserName", config.ServerUsername);
string serverPassword = PAMUtilities.ResolvePAMField(_resolver, _logger, "Server Password", config.ServerPassword);
Expand Down
60 changes: 6 additions & 54 deletions IISU/ImplementedStoreTypes/Win/Management.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
using System.Net;
using Keyfactor.Logging;

namespace Keyfactor.Extensions.Orchestrator.WindowsCertStore.Win
namespace Keyfactor.Extensions.Orchestrator.WindowsCertStore.WinCert
{
public class Management : WinCertJobTypeBase, IManagementJobExtension
{
Expand All @@ -47,11 +47,13 @@ public Management(IPAMSecretResolver resolver)

public JobResult ProcessJob(ManagementJobConfiguration config)
{
_logger = LogHandler.GetClassLogger<Management>();
_logger.MethodEntry();

try
{
_logger = LogHandler.GetClassLogger<Management>();
_logger.MethodEntry();

_logger.LogTrace(JobConfigurationParser.ParseManagementJobConfiguration(config));

string serverUserName = PAMUtilities.ResolvePAMField(_resolver, _logger, "Server UserName", config.ServerUsername);
string serverPassword = PAMUtilities.ResolvePAMField(_resolver, _logger, "Server Password", config.ServerPassword);

Expand Down Expand Up @@ -112,56 +114,6 @@ public JobResult ProcessJob(ManagementJobConfiguration config)
}
}

//private JobResult PerformManagement(ManagementJobConfiguration config)
//{
// try
// {
// _logger.MethodEntry();

// ServerUserName = PAMUtilities.ResolvePAMField(_resolver, _logger, "Server UserName", config.ServerUsername);
// ServerPassword = PAMUtilities.ResolvePAMField(_resolver, _logger, "Server Password", config.ServerPassword);

// var complete = new JobResult
// {
// Result = OrchestratorJobStatusJobResult.Failure,
// JobHistoryId = config.JobHistoryId,
// FailureMessage =
// "Invalid Management Operation"
// };

// switch (config.OperationType)
// {
// case CertStoreOperationType.Add:
// {
// _logger.LogTrace("Adding...");
// if (config.JobProperties.ContainsKey("RenewalThumbprint"))
// {
// _thumbprint = config.JobProperties["RenewalThumbprint"].ToString();
// _logger.LogTrace($"Found Thumbprint Will renew all cers with this Thumbprint: {_thumbprint}");
// }

// _logger.LogTrace("Before PerformAddition...");
// complete = performAddition(config);
// _logger.LogTrace("After PerformAddition...");

// break;
// }
// case CertStoreOperationType.Remove:
// {
// break;
// }
// }

// return complete;
// }

// catch (Exception e)
// {
// _logger.LogError($"Error Occurred in Management.PerformManagement: {e.Message}");
// throw;
// }
//}

private JobResult performAddition(ManagementJobConfiguration config)
{
try
Expand Down
2 changes: 1 addition & 1 deletion IISU/ImplementedStoreTypes/Win/ReEnrollment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
using Keyfactor.Orchestrators.Extensions.Interfaces;
using Microsoft.Extensions.Logging;

namespace Keyfactor.Extensions.Orchestrator.WindowsCertStore.Win
namespace Keyfactor.Extensions.Orchestrator.WindowsCertStore.WinCert
{
public class ReEnrollment : WinCertJobTypeBase, IReenrollmentJobExtension
{
Expand Down
2 changes: 1 addition & 1 deletion IISU/ImplementedStoreTypes/Win/WinInventory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
using System.Management.Automation.Runspaces;
using System.Text;

namespace Keyfactor.Extensions.Orchestrator.WindowsCertStore.Win
namespace Keyfactor.Extensions.Orchestrator.WindowsCertStore.WinCert
{
internal class WinInventory : ClientPSCertStoreInventory
{
Expand Down
6 changes: 3 additions & 3 deletions IISU/ImplementedStoreTypes/WinIIS/IISManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
using Microsoft.Extensions.Logging;
using Newtonsoft.Json;

namespace Keyfactor.Extensions.Orchestrator.WindowsCertStore.WinIIS
namespace Keyfactor.Extensions.Orchestrator.WindowsCertStore.IISU
{
public class IISManager
{
Expand Down Expand Up @@ -66,7 +66,7 @@ public IISManager(ReenrollmentJobConfiguration config, string serverUserName, st
Port = config.JobProperties["Port"].ToString();
HostName = config.JobProperties["HostName"]?.ToString();
Protocol = config.JobProperties["Protocol"].ToString();
SniFlag = config.JobProperties["SniFlag"].ToString()?.Substring(0, 1);
SniFlag = config.JobProperties["SniFlag"].ToString()?[..1];
IpAddress = config.JobProperties["IPAddress"].ToString();

PrivateKeyPassword = ""; // A reenrollment does not have a PFX Password
Expand Down Expand Up @@ -105,7 +105,7 @@ public IISManager(ManagementJobConfiguration config, string serverUserName, stri
Port = config.JobProperties["Port"].ToString();
HostName = config.JobProperties["HostName"]?.ToString();
Protocol = config.JobProperties["Protocol"].ToString();
SniFlag = config.JobProperties["SniFlag"].ToString()?.Substring(0, 1);
SniFlag = config.JobProperties["SniFlag"].ToString()?[..1];
IpAddress = config.JobProperties["IPAddress"].ToString();

PrivateKeyPassword = config.JobCertificate.PrivateKeyPassword;
Expand Down
6 changes: 4 additions & 2 deletions IISU/ImplementedStoreTypes/WinIIS/Inventory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
using Microsoft.Extensions.Logging;
using Newtonsoft.Json;

namespace Keyfactor.Extensions.Orchestrator.WindowsCertStore.WinIIS
namespace Keyfactor.Extensions.Orchestrator.WindowsCertStore.IISU
{
public class Inventory : WinCertJobTypeBase, IInventoryJobExtension
{
Expand All @@ -52,7 +52,9 @@ private JobResult PerformInventory(InventoryJobConfiguration config, SubmitInven
{
var inventoryItems = new List<CurrentInventoryItem>();

_logger.LogTrace($"Job Configuration: {JsonConvert.SerializeObject(config)}");
string myConfig = config.ToString();

_logger.LogTrace(JobConfigurationParser.ParseInventoryJobConfiguration(config));

string serverUserName = PAMUtilities.ResolvePAMField(_resolver, _logger, "Server UserName", config.ServerUsername);
string serverPassword = PAMUtilities.ResolvePAMField(_resolver, _logger, "Server Password", config.ServerPassword);
Expand Down
8 changes: 2 additions & 6 deletions IISU/ImplementedStoreTypes/WinIIS/Management.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,14 @@
using Microsoft.PowerShell.Commands;
using Newtonsoft.Json;

namespace Keyfactor.Extensions.Orchestrator.WindowsCertStore.WinIIS
namespace Keyfactor.Extensions.Orchestrator.WindowsCertStore.IISU
{
public class Management : WinCertJobTypeBase, IManagementJobExtension
{
private ILogger _logger;

public string ExtensionName => string.Empty;

private string _thumbprint = string.Empty;

private Runspace myRunspace;

public Management(IPAMSecretResolver resolver)
Expand All @@ -49,7 +47,7 @@ public JobResult ProcessJob(ManagementJobConfiguration config)
_logger = LogHandler.GetClassLogger<Management>();
_logger.MethodEntry();

_logger.LogTrace($"Job Configuration: {JsonConvert.SerializeObject(config)}");
_logger.LogTrace(JobConfigurationParser.ParseManagementJobConfiguration(config));

string serverUserName = PAMUtilities.ResolvePAMField(_resolver, _logger, "Server UserName", config.ServerUsername);
string serverPassword = PAMUtilities.ResolvePAMField(_resolver, _logger, "Server Password", config.ServerPassword);
Expand Down Expand Up @@ -139,8 +137,6 @@ private JobResult PerformRemoveCertificate(ManagementJobConfiguration config, st
{
_logger.LogTrace("Before Remove Certificate...");

string certificateContents = config.JobCertificate.Contents;
string privateKeyPassword = config.JobCertificate.PrivateKeyPassword;
string storePath = config.CertificateStoreDetails.StorePath;
long jobNumber = config.JobHistoryId;

Expand Down
2 changes: 1 addition & 1 deletion IISU/ImplementedStoreTypes/WinIIS/ReEnrollment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
using Keyfactor.Orchestrators.Extensions.Interfaces;
using Microsoft.Extensions.Logging;

namespace Keyfactor.Extensions.Orchestrator.WindowsCertStore.WinIIS
namespace Keyfactor.Extensions.Orchestrator.WindowsCertStore.IISU
{
public class ReEnrollment: WinCertJobTypeBase, IReenrollmentJobExtension
{
Expand Down
2 changes: 1 addition & 1 deletion IISU/ImplementedStoreTypes/WinIIS/WinIISInventory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
using System.Management.Automation.Runspaces;
using System.Text;

namespace Keyfactor.Extensions.Orchestrator.WindowsCertStore.WinIIS
namespace Keyfactor.Extensions.Orchestrator.WindowsCertStore.IISU
{
internal class WinIISInventory : ClientPSCertStoreInventory
{
Expand Down
11 changes: 11 additions & 0 deletions IISU/Interfaces/ICertificateStoreDetailsBase.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using System;
using System.Collections.Generic;
using System.Text;

namespace Keyfactor.Extensions.Orchestrator.WindowsCertStore
{
internal interface ICertificateStoreDetailsBase
{
public CertificateStoreDetailsDTO CertificateStoreDetails { get; set; }
}
}
7 changes: 7 additions & 0 deletions IISU/Interfaces/IInventoryCertStoreDetails.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace Keyfactor.Extensions.Orchestrator.WindowsCertStore
{
internal interface IInventoryCertStoreDetails
{
public CertificateStoreDetailsDTO CertificateStoreDetails { get; set; }
}
}
10 changes: 10 additions & 0 deletions IISU/Interfaces/IInventoryJobLogger.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
using System;
using System.Collections.Generic;
using System.Text;

namespace Keyfactor.Extensions.Orchestrator.WindowsCertStore
{
internal interface IInventoryJobLogger : IJobConfigurationLoggerBase, IInventoryCertStoreDetails
{
}
}
Loading