Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ab#48867 Add SSH #131

Open
wants to merge 21 commits into
base: release-2.6
Choose a base branch
from
Open
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
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
2.6.0
* Added the ability to run the extension in a Linux environment. To utilize this change, for each Cert Store Types (WinCert/WinIIS/WinSQL), add ssh to the Custom Field <b>WinRM Protocol</b>. When using ssh as a protocol, make sure to enter the appropriate ssh port number under WinRM Port.
* NOTE: For legacy purposes the Display names WinRM Protocol and WinRM Port are maintained although the type of protocols now includes ssh.
* Moved all inventory and management jobs to external PowerShell script file .\PowerShellScripts\WinCertScripts.ps1

2.5.1
* Fixed WinSQL service name when InstanceID differs from InstanceName

Expand Down
43 changes: 21 additions & 22 deletions IISU/Certificate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,11 @@
// See the License for the specific language governing permissions and
// limitations under the License.

// 021225 rcp 2.6.0 Cleaned up and verified code

using Newtonsoft.Json;
using System;
using System.Linq;
using System.Text.RegularExpressions;
using System.Collections.Generic;

namespace Keyfactor.Extensions.Orchestrator.WindowsCertStore
{
Expand All @@ -29,30 +31,27 @@ public class Certificate

public class Utilities
{
public static string FormatSAN(string san)
public static List<T> DeserializeCertificates<T>(string jsonResults)
{
// Use regular expression to extract key-value pairs
var regex = new Regex(@"(?<key>DNS Name|Email|IP Address)=(?<value>[^=,\s]+)");
var matches = regex.Matches(san);

// Format matches into the desired format
string result = string.Join("&", matches.Cast<Match>()
.Select(m => $"{NormalizeKey(m.Groups["key"].Value)}={m.Groups["value"].Value}"));

return result;
}
if (string.IsNullOrEmpty(jsonResults))
{
// Handle no objects returned
return new List<T>();
}

private static string NormalizeKey(string key)
{
return key.ToLower() switch
// Determine if the JSON is an array or a single object
if (jsonResults.TrimStart().StartsWith("["))
{
"dns name" => "dns",
"email" => "email",
"ip address" => "ip",
_ => key.ToLower() // For other types, keep them as-is
};
// It's an array, deserialize as list
return JsonConvert.DeserializeObject<List<T>>(jsonResults);
}
else
{
// It's a single object, wrap it in a list
var singleObject = JsonConvert.DeserializeObject<T>(jsonResults);
return new List<T> { singleObject };
}
}

}
}
}
211 changes: 0 additions & 211 deletions IISU/CertificateStore.cs

This file was deleted.

101 changes: 0 additions & 101 deletions IISU/ClientPSCertStoreInventory.cs

This file was deleted.

Loading
Loading