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 3
3
using System . Collections . Generic ;
4
4
using System . IO ;
5
5
using System . Linq ;
6
+ using System . Net ;
6
7
using System . Net . Http ;
8
+ using System . Security . Cryptography . X509Certificates ;
7
9
using System . Text ;
8
10
using System . Text . RegularExpressions ;
9
11
using System . Threading ;
@@ -591,7 +593,26 @@ private static async Task ExecuteGetRequest(string address, HttpClient httpClien
591
593
private bool IsFeedReachable ( string feed , int timeoutMilliSeconds , int tryCount , bool allowExceptions = true )
592
594
{
593
595
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 ) ;
595
616
596
617
for ( var i = 0 ; i < tryCount ; i ++ )
597
618
{
You can’t perform that action at this time.
0 commit comments