Skip to content

Commit c4ee4a3

Browse files
updated manifest, added additional logging, and wrapped private key in PEM headers before submitting.
1 parent 560c412 commit c4ee4a3

File tree

2 files changed

+28
-5
lines changed

2 files changed

+28
-5
lines changed

alteon-orchestrator/Jobs/Management.cs

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,13 +69,13 @@ protected virtual async Task<JobResult> PerformAddition(string alias, string pfx
6969

7070
byte[] bytes;
7171
X509Certificate2 x509;
72-
string pemCert, pemKey;
72+
string pemCert, privateKeyString;
7373

7474
try
7575
{
7676
bytes = Convert.FromBase64String(entryContents);
7777
x509 = new X509Certificate2(bytes, pfxPassword, X509KeyStorageFlags.Exportable);
78-
(pemCert, pemKey) = GetPemFromPfx(bytes, pfxPassword.ToCharArray());
78+
(pemCert, privateKeyString) = GetPemFromPfx(bytes, pfxPassword.ToCharArray());
7979
}
8080
catch (Exception ex)
8181
{
@@ -87,17 +87,21 @@ protected virtual async Task<JobResult> PerformAddition(string alias, string pfx
8787

8888
if (x509.PrivateKey != null)
8989
{
90+
logger.LogTrace($"Private key is present, setting cert type to {AlteonCertTypes.CERTIFICATE_AND_KEY}");
9091
certType = AlteonCertTypes.CERTIFICATE_AND_KEY; // we import as a pair
9192
}
9293
else
9394
{
9495
if (x509.Subject == x509.Issuer)
9596
{
97+
logger.LogTrace($"Subject = {x509.Issuer}, importing as a trusted CA certificate");
9698
certType = AlteonCertTypes.TRUSTED_CA; // we import as a trusted ca
9799
}
98100
// else we import as intermediate ca (default)
99101
}
100102

103+
logger.LogTrace($"determined type to be {certType}");
104+
101105
if (!string.IsNullOrWhiteSpace(pfxPassword)) // This is a PFX Entry
102106
{
103107
if (string.IsNullOrWhiteSpace(alias))
@@ -113,8 +117,7 @@ protected virtual async Task<JobResult> PerformAddition(string alias, string pfx
113117
// add key and cert separately.
114118
// this needs to be done in the following order: key, then cert (per Alteon support)
115119
logger.LogTrace($"adding key and then certificate for certificate with alias {alias}");
116-
117-
await aClient.AddCertificate(alias, pfxPassword, pemKey, AlteonCertTypes.KEY_ONLY);
120+
await aClient.AddCertificate(alias, pfxPassword, Pemify(privateKeyString), AlteonCertTypes.KEY_ONLY);
118121
await aClient.AddCertificate(alias, pfxPassword, pemCert, AlteonCertTypes.CERT_ONLY);
119122
}
120123
else
@@ -130,6 +133,7 @@ protected virtual async Task<JobResult> PerformAddition(string alias, string pfx
130133

131134
if (ex.InnerException != null)
132135
complete.FailureMessage += " - " + ex.InnerException.Message;
136+
logger.LogError($"an error occurred when attempting to add certificate: {ex.Message}");
133137
}
134138
}
135139

@@ -215,6 +219,11 @@ string Pemify(string ss)
215219
throw;
216220
}
217221
}
218-
222+
223+
private string Pemify(string ss)
224+
{
225+
return ss.Length <= 64 ? ss : ss.Substring(0, 64) + "\n" + Pemify(ss.Substring(64));
226+
}
227+
219228
}
220229
}

integration-manifest.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,20 @@
1212
"orchestrator": {
1313
"keyfactor_platform_version": "10.4",
1414
"UOFramework": "10.4",
15+
"store_types": [
16+
{
17+
"Name": "Alteon Load Balancer",
18+
"ShortName": "AlteonLB",
19+
"SupportedOperations": {
20+
"Inventory": true,
21+
"Add": true,
22+
"Remove": true
23+
},
24+
"ServerRequired": true,
25+
"CustomAliasAllowed": "Optional",
26+
"PrivateKeyAllowed": "Optional"
27+
}
28+
],
1529
"win": {
1630
"supportsCreateStore": false,
1731
"supportsDiscovery": false,

0 commit comments

Comments
 (0)