Skip to content

Commit

Permalink
fix: update code
Browse files Browse the repository at this point in the history
Signed-off-by: Junjie Gao <[email protected]>
  • Loading branch information
JeyJeyGao committed Sep 5, 2023
1 parent 8720cb5 commit e10c491
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions Notation.Plugin.AzureKeyVault/Certificate/CertificateChain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,19 +82,19 @@ 2. non-self-signed leaf cert
var leafCert = certs.First(x => !caSet.Contains(x.SubjectName.Name));

// build the certificate chain
X509Certificate2Collection chain = new X509Certificate2Collection();
var chain = new X509Certificate2Collection();
var currentCert = leafCert;
while (true)
{
chain.Add(currentCert);
var subjectDN = currentCert.SubjectName.Name;
var issuerDN = currentCert.IssuerName.Name;

if (isRootCA(currentCert))
{
break;
}

var subjectDN = currentCert.SubjectName.Name;
var issuerDN = currentCert.IssuerName.Name;
if (!caSet.Remove(issuerDN))
{
throw new PluginException($"Found multiple certificates issued by {issuerDN}");
Expand All @@ -119,9 +119,6 @@ 2. non-self-signed leaf cert
/// </summary>
/// <param name="cert"></param>
/// <returns></returns>
public static bool isRootCA(X509Certificate2 cert)
{
return cert.SubjectName.Name == cert.IssuerName.Name;
}
public static bool isRootCA(X509Certificate2 cert) => cert.SubjectName.Name == cert.IssuerName.Name;
}
}

0 comments on commit e10c491

Please sign in to comment.