aboutsummaryrefslogtreecommitdiffstats
path: root/src/slskd/Program.cs
diff options
context:
space:
mode:
authorJP Dillingham <jp@dillingham.me>2024-11-03 16:47:29 -0600
committerJP Dillingham <jp@dillingham.me>2024-11-03 16:47:29 -0600
commit4d5c0e437065e104a784b7080915ca2bfdd2218c (patch)
tree497f5c4120de95898cad5d92f13cdaeac431bf29 /src/slskd/Program.cs
parent4ada795444443fff7b62d7d75404e6a835f18ec0 (diff)
downloadslskd-4d5c0e437065e104a784b7080915ca2bfdd2218c.tar.gz
add an IHttpClientFactory with SSL disabled
Diffstat (limited to 'src/slskd/Program.cs')
-rw-r--r--src/slskd/Program.cs10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/slskd/Program.cs b/src/slskd/Program.cs
index 3ded2e6b..1ac798c1 100644
--- a/src/slskd/Program.cs
+++ b/src/slskd/Program.cs
@@ -26,6 +26,7 @@ namespace slskd
using System.IO;
using System.Linq;
using System.Net;
+ using System.Net.Http;
using System.Reflection;
using System.Security.Cryptography.X509Certificates;
using System.Text;
@@ -546,6 +547,15 @@ namespace slskd
// this is important to prevent memory leaks
services.AddHttpClient();
+ // add a special HttpClientFactory to DI that disables SSL. access it via:
+ // 'using var http = HttpClientFactory.CreateClient(Constants.IgnoreCertificateErrors)'
+ // thanks Microsoft, makes total sense and surely won't be easy to fuck up later!
+ services.AddHttpClient(Constants.IgnoreCertificateErrors)
+ .ConfigurePrimaryHttpMessageHandler(() => new HttpClientHandler
+ {
+ ServerCertificateCustomValidationCallback = HttpClientHandler.DangerousAcceptAnyServerCertificateValidator,
+ });
+
// add a partially configured instance of SoulseekClient. the Application instance will
// complete configuration at startup.
services.AddSingleton<ISoulseekClient, SoulseekClient>(_ =>