Skip to content

Commit 42e8a28

Browse files
authored
Revert "76022 iis orchestrator 3.0.0 (#165)"
This reverts commit 25f88d6.
1 parent 25f88d6 commit 42e8a28

82 files changed

Lines changed: 406 additions & 5762 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

CHANGELOG.md

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,3 @@
1-
3.0.0
2-
* As of this version of the extension, SANs will be handled through the ODKG Enrollment page in Command, and will no longer use the SAN Entry Parameter. This version, we are removing the Entry Parameter "SAN" from the integration-manifest.json, but will still support previous versions of Command in the event the SAN Entry Parameter is passed. The next major version (4.0) will remove all support for the SAN Entry Parameter.
3-
* Added WinADFS Store Type for rotating certificates in ADFS environments. Please note, only the service-communications certificate is rotated throughout your farm.
4-
* Internal only: Added Integration Tests to aid in future development and testing.
5-
* Improved messaging in the event an Entry Parameter is missing (or does not meet the casing requirements)
6-
* Fixed the SNI/SSL flag being returned during inventory, now returns extended SSL flags
7-
* Fixed the SNI/SSL flag when binding the certificate to allow for extended SSL flags
8-
* Added SSL Flag validation to make sure the bit flag is correct. These are the current SSL Flags (NOTE: Values greater than 4 are only supported in IIS 10 version 1809 and higher. The default value is 0):
9-
* 0 No SNI
10-
* 1 Use SNI
11-
* 2 Use Centralized SSL certificate store.
12-
* 4 Disable HTTP/2.
13-
* 8 Disable OCSP Stapling.
14-
* 16 Disable QUIC.
15-
* 32 Disable TLS 1.3 over TCP.
16-
* 64 Disable Legacy TLS.
17-
18-
2.6.4
19-
* Fixed an issue with SSL Flags greater than 3 were not being applied correctly to newer IIS servers.
20-
* Fixed an issue when formatting private RSA keys when connecting using the ssh protocol.
21-
* When using ssh protocol in containers, the SQL ACL on private keys was not being updating correctly. This has been fixed.
22-
* Updated documentation to indicate that the username and password fields on the Cert Store are automatically added by Command.
23-
241
2.6.3
252
* Fixed re-enrollment or ODKG job when RDN Components contained escaped commas.
263
* Updated renewal job for IIS Certs to delete the old cert if not bound or used by other web sites.

IISU/Certificate.cs

Lines changed: 0 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,9 @@
1414

1515
// 021225 rcp 2.6.0 Cleaned up and verified code
1616

17-
// Ignore Spelling: Keyfactor
18-
19-
using Keyfactor.Logging;
20-
using Microsoft.Extensions.Logging;
2117
using Newtonsoft.Json;
2218
using System;
2319
using System.Collections.Generic;
24-
using System.IO;
2520

2621
namespace Keyfactor.Extensions.Orchestrator.WindowsCertStore
2722
{
@@ -57,79 +52,6 @@ public static List<T> DeserializeCertificates<T>(string jsonResults)
5752
return new List<T> { singleObject };
5853
}
5954
}
60-
61-
public static string WriteCertificateToTempPfx(string certificateContents)
62-
{
63-
if (string.IsNullOrWhiteSpace(certificateContents))
64-
throw new ArgumentException("Certificate contents cannot be null or empty.", nameof(certificateContents));
65-
66-
try
67-
{
68-
// Decode the Base64 string into bytes
69-
byte[] certBytes = Convert.FromBase64String(certificateContents);
70-
71-
// Create a unique temporary directory
72-
string tempDirectory = Path.Combine(Path.GetTempPath(), "CertTemp");
73-
Directory.CreateDirectory(tempDirectory);
74-
75-
// Create a unique filename
76-
string fileName = $"cert_{Guid.NewGuid():N}.pfx";
77-
string filePath = Path.Combine(tempDirectory, fileName);
78-
79-
// Write the bytes to the .pfx file
80-
File.WriteAllBytes(filePath, certBytes);
81-
82-
// Return the path to the newly created file
83-
return filePath;
84-
}
85-
catch (FormatException)
86-
{
87-
throw new InvalidDataException("The provided certificate contents are not a valid Base64 string.");
88-
}
89-
catch (Exception ex)
90-
{
91-
throw new IOException($"Failed to write certificate to temp PFX file: {ex.Message}", ex);
92-
}
93-
}
94-
95-
public static void CleanupTempCertificate(string pfxFilePath)
96-
{
97-
ILogger logger = LogHandler.GetClassLogger<Certificate>();
98-
99-
if (string.IsNullOrWhiteSpace(pfxFilePath))
100-
return;
101-
102-
try
103-
{
104-
if (File.Exists(pfxFilePath))
105-
{
106-
File.Delete(pfxFilePath);
107-
}
108-
109-
string? parentDir = Path.GetDirectoryName(pfxFilePath);
110-
if (!string.IsNullOrEmpty(parentDir) && Directory.Exists(parentDir))
111-
{
112-
// Delete the directory if it's empty
113-
if (Directory.GetFiles(parentDir).Length == 0 &&
114-
Directory.GetDirectories(parentDir).Length == 0)
115-
{
116-
Directory.Delete(parentDir);
117-
}
118-
}
119-
}
120-
catch (IOException ioEx)
121-
{
122-
logger.LogWarning($"Warning: Could not delete temporary file or folder: {ioEx.Message}");
123-
}
124-
catch (UnauthorizedAccessException uaEx)
125-
{
126-
logger.LogWarning($"Warning: Access denied when cleaning up temp file: {uaEx.Message}");
127-
}
128-
catch (Exception ex)
129-
{
130-
logger.LogWarning($"Warning: Unexpected error during cleanup: {ex.Message}");
131-
}
132-
}
13355
}
13456
}
13557
}

IISU/ClientPSCertStoreReEnrollment.cs

Lines changed: 2 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434

3535
namespace Keyfactor.Extensions.Orchestrator.WindowsCertStore
3636
{
37-
public class ClientPSCertStoreReEnrollment
37+
internal class ClientPSCertStoreReEnrollment
3838
{
3939
private readonly ILogger _logger;
4040
private readonly IPAMSecretResolver _resolver;
@@ -44,12 +44,6 @@ public class ClientPSCertStoreReEnrollment
4444
private Collection<PSObject>? _results;
4545
#pragma warning restore CS8632 // The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.
4646

47-
// Empty constructor for testing purposes
48-
public ClientPSCertStoreReEnrollment()
49-
{
50-
_logger = LogHandler.GetClassLogger(typeof(ClientPSCertStoreReEnrollment));
51-
}
52-
5347
public ClientPSCertStoreReEnrollment(ILogger logger, IPAMSecretResolver resolver)
5448
{
5549
_logger = logger;
@@ -71,11 +65,7 @@ public JobResult PerformReEnrollment(ReenrollmentJobConfiguration config, Submit
7165
var subjectText = config.JobProperties["subjectText"] as string;
7266
var providerName = config.JobProperties["ProviderName"] as string;
7367
var keyType = config.JobProperties["keyType"] as string;
74-
75-
// Prior to Version 3.0, SANs were passed using config.JobProperties.
76-
// Now they are passed as a config parameter, but we will check both to maintain backward compatibility.
77-
// Version 3.0 and greater will default to the new SANs parameter.
78-
var SAN = ResolveSANString(config);
68+
var SAN = config.JobProperties["SAN"] as string;
7969

8070
int keySize = 0;
8171
if (config.JobProperties["keySize"] is not null && int.TryParse(config.JobProperties["keySize"].ToString(), out int size))
@@ -383,40 +373,5 @@ private string ImportCertificate(byte[] certificateRawData, string storeName)
383373
}
384374
}
385375

386-
public string ResolveSANString(ReenrollmentJobConfiguration config)
387-
{
388-
if (config == null)
389-
throw new ArgumentNullException(nameof(config));
390-
391-
string sourceUsed;
392-
string sanValue = string.Empty;
393-
394-
if (config.SANs != null && config.SANs.Count > 0)
395-
{
396-
var builder = new SANBuilder(config.SANs);
397-
sanValue = builder.BuildSanString();
398-
sourceUsed = "config.SANs (preferred)";
399-
}
400-
else if (config.JobProperties != null &&
401-
config.JobProperties.TryGetValue("SAN", out object legacySanValue) &&
402-
!string.IsNullOrWhiteSpace(legacySanValue.ToString()))
403-
{
404-
sanValue = legacySanValue.ToString().Trim();
405-
sourceUsed = "config.JobProperties[\"SAN\"] (legacy)";
406-
}
407-
else
408-
{
409-
sanValue = string.Empty;
410-
sourceUsed = "none (no SANs provided)";
411-
}
412-
413-
_logger.LogTrace($"[SAN Resolver] Source used: {sourceUsed}");
414-
if (!string.IsNullOrEmpty(sanValue))
415-
_logger.LogTrace($"[SAN Resolver] Value: {sanValue}");
416-
else
417-
_logger.LogTrace("[SAN Resolver] No SAN values found.");
418-
419-
return sanValue;
420-
}
421376
}
422377
}

0 commit comments

Comments
 (0)