Skip to content

Commit

Permalink
ab#63856
Browse files Browse the repository at this point in the history
  • Loading branch information
Lee Fine committed Oct 10, 2024
1 parent 19d39ff commit 8fd105a
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 13 deletions.
32 changes: 19 additions & 13 deletions CitrixAdcOrchestratorJobExtension/CitrixAdcStore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -428,11 +428,24 @@ public void LinkToIssuer(string cert, string privateKeyPassword, string keyPairN
Logger.MethodEntry(LogLevel.Debug);

sslcertificatechain chain = sslcertificatechain.get(_nss, keyPairName);
//if (chain.chaincomplete == 1)
//{
// Logger.LogDebug($"Certificate {keyPairName} already linked to {chain.chainlinked}");
// return;
//}
sslcertkey certKey = sslcertkey.get(_nss, keyPairName);

X509Certificate2Collection x509CertCollection = new X509Certificate2Collection();
x509CertCollection.Import(Convert.FromBase64String(cert), privateKeyPassword, X509KeyStorageFlags.Exportable | X509KeyStorageFlags.EphemeralKeySet);

X509Certificate2 issuingCert = x509CertCollection.First(r => r.Subject == (x509CertCollection.First(p => p.HasPrivateKey).Issuer));

if (chain.chaincomplete == 1)
{
foreach (string chainCertAlias in chain.chainlinked)
{
X509Certificate2 x509ChainCert = GetX509Certificate(GetKeyPairByName(chainCertAlias));
if (x509ChainCert.Thumbprint == issuingCert.Thumbprint)
{
return;
}
}
}

if (chain.chainpossiblelinks == null || chain.chainpossiblelinks.Length == 0)
{
Expand All @@ -441,15 +454,8 @@ public void LinkToIssuer(string cert, string privateKeyPassword, string keyPairN
throw new LinkException(msg);
}

sslcertkey certKey = sslcertkey.get(_nss, keyPairName);
string chainCertName = string.Empty;

X509Certificate2Collection x509CertCollection = new X509Certificate2Collection();
x509CertCollection.Import(Convert.FromBase64String(cert), privateKeyPassword, X509KeyStorageFlags.Exportable | X509KeyStorageFlags.EphemeralKeySet);

X509Certificate2 issuingCert = x509CertCollection.First(r => r.Subject == (x509CertCollection.First(p => p.HasPrivateKey).Issuer));

foreach(string chainCertAlias in chain.chainpossiblelinks)
foreach (string chainCertAlias in chain.chainpossiblelinks)
{
X509Certificate2 x509ChainCert = GetX509Certificate(GetKeyPairByName(chainCertAlias));
if (x509ChainCert.Thumbprint == issuingCert.Thumbprint)
Expand Down
Binary file modified CitrixAdcTestConsole/bin/Debug/net6.0/CitrixAdcTestConsole.dll
Binary file not shown.
Binary file modified CitrixAdcTestConsole/bin/Debug/net6.0/CitrixAdcTestConsole.exe
Binary file not shown.
Binary file modified CitrixAdcTestConsole/bin/Debug/net6.0/CitrixAdcTestConsole.pdb
Binary file not shown.
Binary file not shown.
Binary file not shown.

0 comments on commit 8fd105a

Please sign in to comment.