Skip to content

Commit

Permalink
Fixed DigitalCertificate.DnsNames to return unicode domain names
Browse files Browse the repository at this point in the history
  • Loading branch information
jstedfast committed Dec 9, 2024
1 parent 5846a22 commit 1532c13
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
6 changes: 6 additions & 0 deletions MimeKit/Cryptography/BouncyCastleCertificateExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,9 @@ static string[] GetSubjectAlternativeNames (X509Certificate certificate, int tag
/// </exception>
public static string GetSubjectEmailAddress (this X509Certificate certificate, bool idnEncode = false)
{
if (certificate == null)
throw new ArgumentNullException (nameof (certificate));

var address = certificate.GetSubjectNameInfo (X509Name.EmailAddress);

if (string.IsNullOrEmpty (address)) {
Expand Down Expand Up @@ -233,6 +236,9 @@ public static string GetSubjectEmailAddress (this X509Certificate certificate, b
/// </exception>
public static string[] GetSubjectDnsNames (this X509Certificate certificate, bool idnEncode = false)
{
if (certificate == null)
throw new ArgumentNullException (nameof (certificate));

var domains = GetSubjectAlternativeNames (certificate, GeneralName.DnsName);

if (idnEncode) {
Expand Down
4 changes: 2 additions & 2 deletions MimeKit/Cryptography/SecureMimeDigitalCertificate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ public string Fingerprint {
/// </remarks>
/// <value>The email address.</value>
public string Email {
get { return Certificate.GetSubjectEmailAddress (true); }
get { return Certificate.GetSubjectEmailAddress (false); }
}

/// <summary>
Expand All @@ -141,7 +141,7 @@ public string Email {
/// </remarks>
/// <value>The DNS name.</value>
public string[] DnsNames {
get { return Certificate.GetSubjectDnsNames (true); }
get { return Certificate.GetSubjectDnsNames (false); }
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ public string Email {
/// </remarks>
/// <value>The DNS name.</value>
public string[] DnsNames {
get { return Certificate.GetSubjectDnsNames (true); }
get { return Certificate.GetSubjectDnsNames (false); }
}

/// <summary>
Expand Down

0 comments on commit 1532c13

Please sign in to comment.