From 093ae39e61cf7cb1f43f7eed15e8d349ef39f7db Mon Sep 17 00:00:00 2001 From: rockstardev Date: Sun, 20 May 2018 10:27:49 -0500 Subject: [PATCH] Custom HTTPS certificates accepted for lnd connection --- .../Lightning/Lnd/LndSwaggerClientCustomHttp.cs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/BTCPayServer/Payments/Lightning/Lnd/LndSwaggerClientCustomHttp.cs b/BTCPayServer/Payments/Lightning/Lnd/LndSwaggerClientCustomHttp.cs index 7f9c92eb5..8f8187615 100644 --- a/BTCPayServer/Payments/Lightning/Lnd/LndSwaggerClientCustomHttp.cs +++ b/BTCPayServer/Payments/Lightning/Lnd/LndSwaggerClientCustomHttp.cs @@ -51,14 +51,20 @@ namespace BTCPayServer.Payments.Lightning.Lnd private static HttpClientHandler GetCertificate(byte[] certFile) { - X509Certificate2 clientCertificate = null; - if (certFile != null) - clientCertificate = new X509Certificate2(certFile); - var handler = new HttpClientHandler { SslProtocols = SslProtocols.Tls12 }; + if (certFile == null) + { + handler.ServerCertificateCustomValidationCallback = HttpClientHandler.DangerousAcceptAnyServerCertificateValidator; + return handler; + } + + // if certificate is not null, try with custom accepting logic + X509Certificate2 clientCertificate = null; + if (certFile != null) + clientCertificate = new X509Certificate2(certFile); handler.ServerCertificateCustomValidationCallback = (request, cert, chain, errors) => {