77using System . Collections . Generic ;
88using System . IO ;
99using System . Linq ;
10+
11+ #if NETFRAMEWORK
12+ using System . Net ;
13+ #endif
14+
1015using System . Net . Http ;
16+
17+ #if ! NETFRAMEWORK
18+
1119using System . Security . Authentication ;
20+
21+ #endif
22+
1223using System . Text . Json ;
1324using System . Text . Json . Serialization ;
1425using System . Text . RegularExpressions ;
@@ -22,7 +33,12 @@ public static class ApiResolver
2233 private static readonly ConcurrentDictionary < string , bool > Releases = new ConcurrentDictionary < string , bool > ( ) ;
2334
2435 private static HttpClient HttpClient { get ; } =
25- new HttpClient ( new HttpClientHandler { SslProtocols = SslProtocols . Tls12 } )
36+ #if NETFRAMEWORK
37+ new HttpClient
38+ #else
39+ // SslProtocols is only available in .NET Framework 4.7.2 and above
40+ new HttpClient ( new HttpClientHandler { SslProtocols = SslProtocols . Tls12 } )
41+ #endif
2642 {
2743 BaseAddress = new Uri ( ArtifactsApiUrl )
2844 } ;
@@ -39,9 +55,10 @@ public static string FetchJson(string path)
3955
4056 public static bool IsReleasedVersion ( string version )
4157 {
42- if ( Releases . TryGetValue ( version , out var released ) ) return released ;
58+ if ( Releases . TryGetValue ( version , out var released ) )
59+ return released ;
4360 var versionPath = "https://github.com/elastic/elasticsearch/releases/tag/v" + version ;
44- var message = new HttpRequestMessage { Method = HttpMethod . Head , RequestUri = new Uri ( versionPath ) } ;
61+ var message = new HttpRequestMessage { Method = HttpMethod . Head , RequestUri = new Uri ( versionPath ) } ;
4562
4663 using ( var response = HttpClient . SendAsync ( message ) . GetAwaiter ( ) . GetResult ( ) )
4764 {
@@ -76,6 +93,14 @@ public static string GetBuildHash(string url)
7693
7794 return tokens [ 1 ] ;
7895 }
96+
97+ #if NETFRAMEWORK
98+ static ApiResolver ( ) =>
99+ ServicePointManager . SecurityProtocol = ServicePointManager . SecurityProtocol
100+ & ~ SecurityProtocolType . Ssl3
101+ & ~ SecurityProtocolType . Tls
102+ & ~ SecurityProtocolType . Tls11 ;
103+ #endif
79104 }
80105
81106 internal class ArtifactsVersionsResponse
0 commit comments