File tree Expand file tree Collapse file tree 1 file changed +22
-1
lines changed
Expand file tree Collapse file tree 1 file changed +22
-1
lines changed Original file line number Diff line number Diff line change 33using System . Collections . Generic ;
44using System . IO ;
55using System . Linq ;
6+ using System . Net ;
67using System . Net . Http ;
8+ using System . Security . Cryptography . X509Certificates ;
79using System . Text ;
810using System . Text . RegularExpressions ;
911using System . Threading ;
@@ -591,7 +593,26 @@ private static async Task ExecuteGetRequest(string address, HttpClient httpClien
591593 private bool IsFeedReachable ( string feed , int timeoutMilliSeconds , int tryCount , bool allowExceptions = true )
592594 {
593595 logger . LogInfo ( $ "Checking if Nuget feed '{ feed } ' is reachable...") ;
594- using HttpClient client = new ( ) ;
596+
597+ // Configure the HttpClient to be aware of the Dependabot Proxy, if used.
598+ HttpClientHandler httpClientHandler = new ( ) ;
599+ if ( this . dependabotProxy . IsConfigured )
600+ {
601+ httpClientHandler . Proxy = new WebProxy ( this . dependabotProxy . Address ) ;
602+
603+ if ( ! String . IsNullOrEmpty ( this . dependabotProxy . CertificatePath ) )
604+ {
605+ X509Certificate2 proxyCert = new X509Certificate2 ( this . dependabotProxy . CertificatePath ) ;
606+ httpClientHandler . ServerCertificateCustomValidationCallback = ( message , cert , chain , _ ) =>
607+ {
608+ chain . ChainPolicy . TrustMode = X509ChainTrustMode . CustomRootTrust ;
609+ chain . ChainPolicy . CustomTrustStore . Add ( proxyCert ) ;
610+ return chain . Build ( cert ) ;
611+ } ;
612+ }
613+ }
614+
615+ using HttpClient client = new ( httpClientHandler ) ;
595616
596617 for ( var i = 0 ; i < tryCount ; i ++ )
597618 {
You can’t perform that action at this time.
0 commit comments