@@ -25,32 +25,6 @@ public static class EndpointUtility
2525 {
2626 private const string AllowedPackageUri = "https://packages.virtualclient.microsoft.com" ;
2727
28- #pragma warning disable CS1570 // XML comment has badly formed XML - the URI is not XML
29- /// <summary>
30- /// Parses the subject name and issuer from the provided uri. If the uri does not contain the correctly formatted certificate subject name
31- /// and issuer information the method will return false, and keep the two out parameters as null.
32- /// Ex. https://vegaprod01proxyapi.azurewebsites.net?crti=issuerName&crts=certSubject
33- /// </summary>
34- /// <param name="uri">The uri to attempt to parse the values from.</param>
35- /// <param name="issuer">The issuer of the certificate.</param>
36- /// <param name="subject">The subject of the certificate.</param>
37- /// <returns>True/False if the method was able to successfully parse both the subject name and the issuer of the certificate.</returns>
38- public static bool TryParseCertificateReference ( Uri uri , out string issuer , out string subject )
39- #pragma warning restore CS1570 // XML comment has badly formed XML
40- {
41- IDictionary < string , IConvertible > values = TextParsingExtensions . ParseDelimitedValues ( uri . Query ) ;
42-
43- issuer = values . TryGetValue ( "crti" , out IConvertible iss ) ? iss . ToString ( ) : null ;
44- subject = values . TryGetValue ( "crts" , out IConvertible sub ) ? sub . ToString ( ) : null ;
45-
46- if ( ! string . IsNullOrWhiteSpace ( issuer ) && ! string . IsNullOrWhiteSpace ( subject ) )
47- {
48- return true ;
49- }
50-
51- return false ;
52- }
53-
5428 /// <summary>
5529 /// Creates a <see cref="DependencyBlobStore"/> definition from the connection properties provided.
5630 /// <list>
@@ -403,6 +377,25 @@ public static bool IsPackageUri(Uri endpointUri, string storeName)
403377 return storeName == DependencyStore . Packages && packageUri ;
404378 }
405379
380+ /// <summary>
381+ /// Parses the subject name and issuer from the provided uri. If the uri does not contain the correctly formatted certificate subject name
382+ /// and issuer information the method will return false, and keep the two out parameters as null.
383+ /// Ex. https://vegaprod01proxyapi.azurewebsites.net?crti=issuerName&crts=certSubject
384+ /// </summary>
385+ /// <param name="uri">The uri to attempt to parse the values from.</param>
386+ /// <param name="issuer">The issuer of the certificate.</param>
387+ /// <param name="subject">The subject of the certificate.</param>
388+ /// <returns>True/False if the method was able to successfully parse both the subject name and the issuer of the certificate.</returns>
389+ public static bool TryParseCertificateReference ( Uri uri , out string issuer , out string subject )
390+ {
391+ IDictionary < string , string > queryParameters = TextParsingExtensions . ParseDelimitedValues ( uri . Query ) ? . ToDictionary (
392+ entry => entry . Key ,
393+ entry => entry . Value ? . ToString ( ) ,
394+ StringComparer . OrdinalIgnoreCase ) ;
395+
396+ return TryGetCertificateReferenceForUri ( queryParameters , out issuer , out subject ) ;
397+ }
398+
406399 /// <summary>
407400 /// Returns the endpoint by verifying package uri checks.
408401 /// if the endpoint is a package uri without http or https protocols then append the protocol else return the endpoint value.
0 commit comments