1818
1919using System ;
2020using System . Collections . Generic ;
21+ using System . Globalization ;
2122using System . Security . Cryptography . X509Certificates ;
2223
2324namespace Grpc . AspNetCore . Server . Internal
@@ -35,7 +36,7 @@ public static string[] GetDnsFromExtensions(X509Certificate2 cert)
3536 string asnString = ext . Format ( false ) ;
3637 if ( string . IsNullOrWhiteSpace ( asnString ) )
3738 {
38- return new string [ 0 ] ;
39+ return Array . Empty < string > ( ) ;
3940 }
4041
4142 // SubjectAlternativeNames might contain something other than a dNSName,
@@ -50,7 +51,7 @@ public static string[] GetDnsFromExtensions(X509Certificate2 cert)
5051 for ( var i = 0 ; i < rawDnsEntries . Length ; i ++ )
5152 {
5253 string [ ] keyval = rawDnsEntries [ i ] . Split ( X509SubjectAlternativeNameConstants . Delimiter ) ;
53- if ( string . Equals ( keyval [ 0 ] , X509SubjectAlternativeNameConstants . Identifier ) )
54+ if ( string . Equals ( keyval [ 0 ] , X509SubjectAlternativeNameConstants . Identifier , StringComparison . Ordinal ) )
5455 {
5556 dnsEntries . Add ( keyval [ 1 ] ) ;
5657 }
@@ -59,7 +60,7 @@ public static string[] GetDnsFromExtensions(X509Certificate2 cert)
5960 return dnsEntries . ToArray ( ) ;
6061 }
6162 }
62- return new string [ 0 ] ;
63+ return Array . Empty < string > ( ) ;
6364 }
6465
6566 // We don't have a strongly typed extension to parse Subject Alt Names, so we have to do a workaround
@@ -106,6 +107,7 @@ private static void EnsureInitialized()
106107 if ( ! s_successfullyInitialized )
107108 {
108109 throw new FormatException ( string . Format (
110+ CultureInfo . InvariantCulture ,
109111 "There was an error detecting the identifier, delimiter, and separator for X509CertificateClaims on this platform.{0}" +
110112 "Detected values were: Identifier: '{1}'; Delimiter:'{2}'; Separator:'{3}'" ,
111113 Environment . NewLine ,
@@ -138,7 +140,7 @@ static X509SubjectAlternativeNameConstants()
138140 // Linux: x509ExtensionFormattedString is: "DNS:not-real-subject-name, DNS:example.com"
139141 // Parse: <identifier><delimter><value><separator(s)>
140142
141- int delimiterIndex = x509ExtensionFormattedString . IndexOf ( subjectName1 ) - 1 ;
143+ int delimiterIndex = x509ExtensionFormattedString . IndexOf ( subjectName1 , StringComparison . Ordinal ) - 1 ;
142144 s_delimiter = x509ExtensionFormattedString [ delimiterIndex ] ;
143145
144146 // Make an assumption that all characters from the the start of string to the delimiter
0 commit comments