Custom HTTPS certificates accepted for lnd connection

This commit is contained in:
rockstardev 2018-05-20 10:27:49 -05:00
parent cac58808f0
commit 093ae39e61

View file

@ -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) =>
{