Skip to content

Commit 09c10a7

Browse files
committed
Use TLS 1.2 with artifacts API
This commit restricts supported SSL protocols to TLS 1.2 when calling the artifiacts API. It's possible that a user's machine has older versions of .NET framework installed that default to allow TLS 1.0, causing the request to fail with: The request was aborted: Could not create SSL/TLS secure channel.
1 parent 22192b9 commit 09c10a7

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/Elastic.Stack.Artifacts/Resolvers/SnapshotApiResolver.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@
22
using System.Collections.Generic;
33
using System.IO;
44
using System.Linq;
5+
using System.Net;
56
using System.Net.Http;
67
using System.Runtime.InteropServices;
8+
using System.Security.Authentication;
79
using System.Text.Json.Serialization;
810
using System.Text.RegularExpressions;
911
using System.Threading;
@@ -106,7 +108,11 @@ public static Version LatestReleaseOrSnapshotForMajor(int major)
106108
.FirstOrDefault(v => range.IsSatisfied(v.ToString().Replace("-SNAPSHOT", "")));
107109
}
108110

109-
private static HttpClient HttpClient { get; } = new HttpClient() { BaseAddress = new Uri(ArtifactsApiUrl) };
111+
private static HttpClient HttpClient { get; } = new HttpClient(new HttpClientHandler
112+
{
113+
SslProtocols = SslProtocols.Tls12
114+
}) { BaseAddress = new Uri(ArtifactsApiUrl) };
115+
110116
private static string FetchJson(string path)
111117
{
112118
using (var stream = HttpClient.GetStreamAsync(path).GetAwaiter().GetResult())

0 commit comments

Comments
 (0)