Skip to content

Commit

Permalink
Merge branch 'PKCE' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
JoeShook committed Sep 19, 2024
2 parents 9ed126a + d87e6c5 commit 1712efe
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
8 changes: 7 additions & 1 deletion Udap.Util/Extensions/X509Extensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -291,9 +291,15 @@ private static Asn1Object GetObject(byte[] ext)

public static List<Tuple<string, string>> GetSubjectAltNames(this X509Certificate2 cert, Func<GeneralName, bool>? sanFilter = null)
{
var names = new List<Tuple<string, string>>();
var extension = cert.GetExtensionValue("2.5.29.17");

if (extension == null)
{
return names;
}

var generalNames = GeneralNames.GetInstance(extension);
var names = new List<Tuple<string, string>>();

foreach (var name in generalNames.GetNames().Where(sanFilter ?? (n => true)))
{
Expand Down
9 changes: 9 additions & 0 deletions _tests/Udap.Common.Tests/Util/X509ExtensionTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,13 @@ public void KeyUsageTest()

extensions.Single().KeyUsages.ToKeyUsageToString().Should().ContainInOrder("CrlSign", "KeyCertSign");
}

[Fact]
public void GetSubjectAltNames()
{
var certificate = new X509Certificate2($"{CertStore}/SurefhirCertificationLabs_Community/issued/FhirLabsAdminCertification.cer");

var subjectAltNames = certificate.GetSubjectAltNames();
subjectAltNames.Should().BeEmpty();
}
}

0 comments on commit 1712efe

Please sign in to comment.