Skip to content

Commit 8f9a179

Browse files
authored
Merge 0d23e12 into 9fcf193
2 parents 9fcf193 + 0d23e12 commit 8f9a179

File tree

6 files changed

+134
-199
lines changed

6 files changed

+134
-199
lines changed

.github/workflows/keyfactor-starter-workflow.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ on:
1111

1212
jobs:
1313
call-starter-workflow:
14-
uses: keyfactor/actions/.github/workflows/starter.yml@3.1.2
14+
uses: keyfactor/actions/.github/workflows/starter.yml@v3
1515
secrets:
1616
token: ${{ secrets.V2BUILDTOKEN}}
1717
APPROVE_README_PUSH: ${{ secrets.APPROVE_README_PUSH}}

CHANGELOG.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
1+
2.5.2
2+
* Fixed a PowerShell compatibility issue when using LocalMachine. LocalMachine will always run PowerShell 5.1.
3+
14
2.5.1
25
* Fixed WinSQL service name when InstanceID differs from InstanceName
36

47
2.5.0
58
* Added the Bindings to the end of the thumbprint to make the alias unique.
69
* Using new IISWebBindings commandlet to use additional SSL flags when binding certificate to website.
710
* Added multi-platform support for .Net6 and .Net8.
8-
* Updated various PowerShell scripts to handle both .Net6 and .Net8 differences (specifically the absense of the WebAdministration module in PS SDK 7.4.x+)
11+
* Updated various PowerShell scripts to handle both .Net6 and .Net8 differences (specifically the absence of the WebAdministration module in PS SDK 7.4.x+)
912
* Fixed issue to update multiple websites when using the same cert.
1013
* Removed renewal thumbprint logic to update multiple website; each job now updates its own specific certificate.
1114

IISU/ClientPSIIManager.cs

Lines changed: 1 addition & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -567,78 +567,7 @@ private object PerformIISUnBinding(string webSiteName, string protocol, string i
567567
/// <returns></returns>
568568
private object PerformIISBinding(string webSiteName, string protocol, string ipAddress, string port, string hostName, string sslFlags, string thumbprint, string storeName)
569569
{
570-
//string funcScript = @"
571-
// param (
572-
// $SiteName, # The name of the IIS site
573-
// $IPAddress, # The IP Address for the binding
574-
// $Port, # The port number for the binding
575-
// $Hostname, # Hostname for the binding (if any)
576-
// $Protocol, # Protocol (e.g., HTTP, HTTPS)
577-
// $Thumbprint, # Certificate thumbprint for HTTPS bindings
578-
// $StoreName, # Certificate store location (e.g., ""My"" for personal certs)
579-
// $SslFlags # SSL flags (if any)
580-
// )
581-
582-
// # Set Execution Policy (optional, depending on your environment)
583-
// Set-ExecutionPolicy -ExecutionPolicy Bypass -Scope Process -Force
584-
585-
// ## Check if the IISAdministration module is available
586-
// #$module = Get-Module -Name IISAdministration -ListAvailable
587-
588-
// #if (-not $module) {
589-
// # throw ""The IISAdministration module is not installed on this system.""
590-
// #}
591-
592-
// # Check if the IISAdministration module is already loaded
593-
// if (-not (Get-Module -Name IISAdministration)) {
594-
// try {
595-
// # Attempt to import the IISAdministration module
596-
// Import-Module IISAdministration -ErrorAction Stop
597-
// }
598-
// catch {
599-
// throw ""Failed to load the IISAdministration module. Ensure it is installed and available.""
600-
// }
601-
// }
602-
603-
// # Retrieve the existing binding information
604-
// $myBinding = ""${IPAddress}:${Port}:${Hostname}""
605-
// Write-Host ""myBinding: "" $myBinding
606-
607-
// $siteBindings = Get-IISSiteBinding -Name $SiteName
608-
// $existingBinding = $siteBindings | Where-Object { $_.bindingInformation -eq $myBinding -and $_.protocol -eq $Protocol }
609-
610-
// Write-Host ""Binding:"" $existingBinding
611-
612-
// if ($null -ne $existingBinding) {
613-
// # Remove the existing binding
614-
// Remove-IISSiteBinding -Name $SiteName -BindingInformation $existingBinding.BindingInformation -Protocol $existingBinding.Protocol -Confirm:$false
615-
616-
// Write-Host ""Removed existing binding: $($existingBinding.BindingInformation)""
617-
// }
618-
619-
// # Create the new binding with modified properties
620-
// $newBindingInfo = ""${IPAddress}:${Port}:${Hostname}""
621-
622-
// try
623-
// {
624-
// New-IISSiteBinding -Name $SiteName `
625-
// -BindingInformation $newBindingInfo `
626-
// -Protocol $Protocol `
627-
// -CertificateThumbprint $Thumbprint `
628-
// -CertStoreLocation $StoreName `
629-
// -SslFlag $SslFlags
630-
631-
// Write-Host ""New binding added: $newBindingInfo""
632-
// }
633-
// catch {
634-
// throw $_
635-
// }
636-
//";
637-
#if NET6_0
638-
string funcScript = PowerShellScripts.UpdateIISBindingsV6;
639-
#elif NET8_0_OR_GREATER
640-
string funcScript = PowerShellScripts.UpdateIISBindingsV8;
641-
#endif
570+
string funcScript = PowerShellScripts.UpdateIISBindings;
642571

643572
ps.AddScript(funcScript);
644573
ps.AddParameter("SiteName", webSiteName);

IISU/PSHelper.cs

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -50,22 +50,10 @@ public static Runspace GetClientPsRunspace(string winRmProtocol, string clientMa
5050

5151
if (isLocal)
5252
{
53-
#if NET6_0
53+
_logger.LogTrace("Establishing a local RunSpace.");
5454
PowerShellProcessInstance instance = new PowerShellProcessInstance(new Version(5, 1), null, null, false);
5555
Runspace rs = RunspaceFactory.CreateOutOfProcessRunspace(new TypeTable(Array.Empty<string>()), instance);
5656
return rs;
57-
#elif NET8_0_OR_GREATER
58-
try
59-
{
60-
InitialSessionState iss = InitialSessionState.CreateDefault();
61-
Runspace rs = RunspaceFactory.CreateRunspace(iss);
62-
return rs;
63-
}
64-
catch (global::System.Exception)
65-
{
66-
throw new Exception($"An error occurred while attempting to create the PowerShell instance. This version requires .Net8 and PowerShell SDK 7.2 or greater. Please verify the version of .Net8 and PowerShell installed on your machine.");
67-
}
68-
#endif
6957
}
7058
else
7159
{

IISU/Scripts/PowerShellScripts.cs

Lines changed: 1 addition & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -8,68 +8,7 @@ namespace Keyfactor.Extensions.Orchestrator.WindowsCertStore.Scripts
88
{
99
public class PowerShellScripts
1010
{
11-
public const string UpdateIISBindingsV6 = @"
12-
param (
13-
$SiteName, # The name of the IIS site
14-
$IPAddress, # The IP Address for the binding
15-
$Port, # The port number for the binding
16-
$Hostname, # Hostname for the binding (if any)
17-
$Protocol, # Protocol (e.g., HTTP, HTTPS)
18-
$Thumbprint, # Certificate thumbprint for HTTPS bindings
19-
$StoreName, # Certificate store location (e.g., ""My"" for personal certs)
20-
$SslFlags # SSL flags (if any)
21-
)
22-
23-
# Set Execution Policy (optional, depending on your environment)
24-
Set-ExecutionPolicy -ExecutionPolicy Bypass -Scope Process -Force
25-
26-
# Check if the WebAdministration module is available
27-
$module = Get-Module -Name WebAdministration -ListAvailable
28-
29-
if (-not $module) {
30-
throw ""The WebAdministration module is not installed on this system.""
31-
}
32-
33-
# Check if the WebAdministration module is already loaded
34-
if (-not (Get-Module -Name WebAdministration)) {
35-
try {
36-
# Attempt to import the WebAdministration module
37-
Import-Module WebAdministration -ErrorAction Stop
38-
}
39-
catch {
40-
throw ""Failed to load the WebAdministration module. Ensure it is installed and available.""
41-
}
42-
}
43-
44-
# Retrieve the existing binding information
45-
$myBinding = ""${IPAddress}:${Port}:${Hostname}""
46-
Write-Host ""myBinding: "" $myBinding
47-
48-
$siteBindings = Get-IISSiteBinding -Name $SiteName
49-
$existingBinding = $siteBindings | Where-Object { $_.bindingInformation -eq $myBinding -and $_.protocol -eq $Protocol }
50-
51-
Write-Host ""Binding:"" $existingBinding
52-
53-
if ($null -ne $existingBinding) {
54-
# Remove the existing binding
55-
Remove-IISSiteBinding -Name $SiteName -BindingInformation $existingBinding.BindingInformation -Protocol $existingBinding.Protocol -Confirm:$false
56-
57-
Write-Host ""Removed existing binding: $($existingBinding.BindingInformation)""
58-
}
59-
60-
# Create the new binding with modified properties
61-
$newBindingInfo = ""${IPAddress}:${Port}:${Hostname}""
62-
63-
New-IISSiteBinding -Name $SiteName `
64-
-BindingInformation $newBindingInfo `
65-
-Protocol $Protocol `
66-
-CertificateThumbprint $Thumbprint `
67-
-CertStoreLocation $StoreName `
68-
-SslFlag $SslFlags
69-
70-
Write-Host ""New binding added: $newBindingInfo""";
71-
72-
public const string UpdateIISBindingsV8 = @"
11+
public const string UpdateIISBindings = @"
7312
param (
7413
$SiteName, # The name of the IIS site
7514
$IPAddress, # The IP Address for the binding

0 commit comments

Comments
 (0)