File tree Expand file tree Collapse file tree 1 file changed +22
-2
lines changed Expand file tree Collapse file tree 1 file changed +22
-2
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 ;
7
- using System . Security . Cryptography ;
8
+ using System . Security . Cryptography . X509Certificates ;
8
9
using System . Text ;
9
10
using System . Text . RegularExpressions ;
10
11
using System . Threading ;
@@ -592,7 +593,26 @@ private static async Task ExecuteGetRequest(string address, HttpClient httpClien
592
593
private bool IsFeedReachable ( string feed , int timeoutMilliSeconds , int tryCount , bool allowExceptions = true )
593
594
{
594
595
logger . LogInfo ( $ "Checking if Nuget feed '{ feed } ' is reachable...") ;
595
- 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 ) ;
596
616
597
617
for ( var i = 0 ; i < tryCount ; i ++ )
598
618
{
You can’t perform that action at this time.
0 commit comments