Skip to content

Commit a999c44

Browse files
authored
Merge pull request #12 from Keyfactor/ab#70161
Ab#70161
2 parents acbcd83 + 5928a26 commit a999c44

File tree

7 files changed

+210
-212
lines changed

7 files changed

+210
-212
lines changed

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

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,17 @@ on:
1111

1212
jobs:
1313
call-starter-workflow:
14-
uses: keyfactor/actions/.github/workflows/[email protected]
14+
uses: keyfactor/actions/.github/workflows/starter.yml@v4
15+
with:
16+
command_token_url: ${{ vars.COMMAND_TOKEN_URL }} # Only required for doctool generated screenshots
17+
command_hostname: ${{ vars.COMMAND_HOSTNAME }} # Only required for doctool generated screenshots
18+
command_base_api_path: ${{ vars.COMMAND_API_PATH }} # Only required for doctool generated screenshots
1519
secrets:
16-
token: ${{ secrets.V2BUILDTOKEN}}
17-
APPROVE_README_PUSH: ${{ secrets.APPROVE_README_PUSH}}
18-
gpg_key: ${{ secrets.KF_GPG_PRIVATE_KEY }}
19-
gpg_pass: ${{ secrets.KF_GPG_PASSPHRASE }}
20-
scan_token: ${{ secrets.SAST_TOKEN }}
20+
token: ${{ secrets.V2BUILDTOKEN}} # REQUIRED
21+
gpg_key: ${{ secrets.KF_GPG_PRIVATE_KEY }} # Only required for golang builds
22+
gpg_pass: ${{ secrets.KF_GPG_PASSPHRASE }} # Only required for golang builds
23+
scan_token: ${{ secrets.SAST_TOKEN }} # REQUIRED
24+
entra_username: ${{ secrets.DOCTOOL_ENTRA_USERNAME }} # Only required for doctool generated screenshots
25+
entra_password: ${{ secrets.DOCTOOL_ENTRA_PASSWD }} # Only required for doctool generated screenshots
26+
command_client_id: ${{ secrets.COMMAND_CLIENT_ID }} # Only required for doctool generated screenshots
27+
command_client_secret: ${{ secrets.COMMAND_CLIENT_SECRET }} # Only required for doctool generated screenshots

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
v2.0.0
2+
- Modify ODKG (Reenrollment) functionality to make use of the Keyfactor Command/UO 25.3 functionality to support SANs, Alias, and Overwrite indicator. Entry parameters SANs, Alias, and Overwrite will no longer be supported.
3+
14
v1.2.0
25
- Documentation updated to use doctool and dual build for .net6/8.
36

F5BigIQ/F5BigIQ.csproj

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,14 @@
99

1010
<ItemGroup>
1111
<PackageReference Include="Keyfactor.Logging" Version="1.1.1" />
12-
<PackageReference Include="Keyfactor.Orchestrators.IOrchestratorJobExtensions" Version="0.7.0" />
12+
<PackageReference Include="Keyfactor.Orchestrators.IOrchestratorJobExtensions" Version="1.0.0" />
1313
<PackageReference Include="Keyfactor.PKI" Version="5.5.0" />
14-
<PackageReference Include="RestSharp" Version="110.2.0" />
14+
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
15+
<PackageReference Include="RestSharp" Version="112.1.0" />
1516
<PackageReference Include="SSH.NET" Version="2024.0.0" />
17+
<Reference Include="Keyfactor.Orchestrators.IOrchestratorJobExtensions">
18+
<HintPath>External References\Keyfactor.Orchestrators.IOrchestratorJobExtensions.dll</HintPath>
19+
</Reference>
1620

1721
<None Update="manifest.json">
1822
<CopyToOutputDirectory>Always</CopyToOutputDirectory>

F5BigIQ/Reenrollment.cs

Lines changed: 27 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
using System;
99
using System.Collections.Generic;
10+
using System.Net.NetworkInformation;
1011
using System.Security.Cryptography.X509Certificates;
1112

1213
using Keyfactor.Logging;
@@ -19,6 +20,8 @@
1920
using Newtonsoft.Json;
2021
using Org.BouncyCastle.X509;
2122
using System.Text;
23+
using Microsoft.Win32.SafeHandles;
24+
using static Org.BouncyCastle.Math.EC.ECCurve;
2225

2326
namespace Keyfactor.Extensions.Orchestrator.F5BigIQ
2427
{
@@ -40,7 +43,7 @@ public JobResult ProcessJob(ReenrollmentJobConfiguration config, SubmitReenrollm
4043
{
4144
logger.LogDebug($" {keyValue.Key}: {keyValue.Value}");
4245
}
43-
46+
4447
dynamic properties = JsonConvert.DeserializeObject(config.CertificateStoreDetails.Properties);
4548

4649
SetPAMSecrets(config.ServerUsername, config.ServerPassword, logger);
@@ -53,27 +56,39 @@ public JobResult ProcessJob(ReenrollmentJobConfiguration config, SubmitReenrollm
5356
string keyType = !config.JobProperties.ContainsKey("keyType") || config.JobProperties["keyType"] == null || string.IsNullOrEmpty(config.JobProperties["keyType"].ToString()) ? string.Empty : config.JobProperties["keyType"].ToString();
5457
int? keySize = !config.JobProperties.ContainsKey("keySize") || config.JobProperties["keySize"] == null || string.IsNullOrEmpty(config.JobProperties["keySize"].ToString()) ? null : Convert.ToInt32(config.JobProperties["keySize"]);
5558
string subjectText = !config.JobProperties.ContainsKey("subjectText") || config.JobProperties["subjectText"] == null || config.JobProperties["subjectText"] == null || string.IsNullOrEmpty(config.JobProperties["subjectText"].ToString()) ? string.Empty : config.JobProperties["subjectText"].ToString();
56-
string sans = !config.JobProperties.ContainsKey("SANs") || config.JobProperties["SANs"] == null || string.IsNullOrEmpty(config.JobProperties["SANs"].ToString()) ? string.Empty : config.JobProperties["SANs"].ToString();
57-
if (!config.JobProperties.ContainsKey("Alias") || config.JobProperties["Alias"] == null || config.JobProperties["Alias"] == null || string.IsNullOrEmpty(config.JobProperties["Alias"].ToString()))
59+
if (string.IsNullOrEmpty(config.Alias))
5860
{
59-
string errorMessage = "Error performing reenrollment. Alias blank or does not exist.";
61+
string errorMessage = "Error performing reenrollment. Alias is required.";
6062
logger.LogError(errorMessage);
6163
return new JobResult() { Result = OrchestratorJobStatusJobResult.Failure, JobHistoryId = config.JobHistoryId, FailureMessage = $"Site {config.CertificateStoreDetails.StorePath} on server {config.CertificateStoreDetails.ClientMachine}: {errorMessage}"};
6264
}
63-
string alias = config.JobProperties["Alias"].ToString();
64-
bool overwrite = !config.JobProperties.ContainsKey("Overwrite") || config.JobProperties["Overwrite"] == null || string.IsNullOrEmpty(config.JobProperties["Overwrite"].ToString()) ? false : Convert.ToBoolean(config.JobProperties["Overwrite"]);
6565

6666
try
6767
{
6868
F5BigIQClient f5Client = new F5BigIQClient(config.CertificateStoreDetails.ClientMachine, config.CertificateStoreDetails.StorePath, ServerUserName, ServerPassword, loginProviderName, useTokenAuthentication, ignoreSSLWarning);
6969

70-
int totalKeys = f5Client.GetKeyByName(alias).TotalItems;
71-
if (!overwrite && totalKeys > 0)
70+
int totalKeys = f5Client.GetKeyByName(config.Alias).TotalItems;
71+
if (!config.Overwrite && totalKeys > 0)
72+
{
73+
throw new Exception($"Alias {config.Alias} already exists, but Overwrite is set to False. Overwrite must be set to True if you wish to perform reenrollment on an existing alias.");
74+
}
75+
76+
string sans = string.Empty;
77+
if (config.SANs.Count > 0)
7278
{
73-
throw new Exception($"Alias {alias} already exists, but Overwrite is set to False. Overwrite must be set to True if you wish to perform reenrollment on an existing alias.");
79+
foreach(KeyValuePair<string, string[]> keyValue in config.SANs)
80+
{
81+
string key = keyValue.Key.Replace("ip4", "ip", StringComparison.OrdinalIgnoreCase).Replace("ip6", "ip", StringComparison.OrdinalIgnoreCase).Replace("upn", "uri", StringComparison.OrdinalIgnoreCase);
82+
foreach (string value in keyValue.Value)
83+
{
84+
sans += (key + ":" + value + ",");
85+
}
86+
}
87+
if (sans.Length > 0)
88+
sans = sans.Substring(0, sans.Length - 1);
7489
}
7590

76-
string csr = f5Client.GenerateCSR(alias, totalKeys > 0, subjectText, keyType, keySize, sans);
91+
string csr = f5Client.GenerateCSR(config.Alias, totalKeys > 0, subjectText, keyType, keySize, sans);
7792

7893
X509Certificate2 cert = submitReenrollment.Invoke(csr);
7994
if (cert == null)
@@ -87,8 +102,8 @@ public JobResult ProcessJob(ReenrollmentJobConfiguration config, SubmitReenrollm
87102

88103
try
89104
{
90-
f5Client.AddReplaceBindCertificate(alias, Convert.ToBase64String(pemBytes),
91-
string.Empty, overwrite, deployCertificateOnRenewal, F5BigIQClient.CERT_FILE_TYPE_TO_ADD.CERT);
105+
f5Client.AddReplaceBindCertificate(config.Alias, Convert.ToBase64String(pemBytes),
106+
string.Empty, config.Overwrite, deployCertificateOnRenewal, F5BigIQClient.CERT_FILE_TYPE_TO_ADD.CERT);
92107
}
93108
catch (F5BigIQException ex)
94109
{

0 commit comments

Comments
 (0)