mirror of
https://github.com/btcpayserver/btcpayserver.git
synced 2025-02-22 14:22:40 +01:00
Custom HTTPS certificates accepted for lnd connection
This commit is contained in:
parent
cac58808f0
commit
093ae39e61
1 changed files with 10 additions and 4 deletions
|
@ -51,14 +51,20 @@ namespace BTCPayServer.Payments.Lightning.Lnd
|
||||||
|
|
||||||
private static HttpClientHandler GetCertificate(byte[] certFile)
|
private static HttpClientHandler GetCertificate(byte[] certFile)
|
||||||
{
|
{
|
||||||
X509Certificate2 clientCertificate = null;
|
|
||||||
if (certFile != null)
|
|
||||||
clientCertificate = new X509Certificate2(certFile);
|
|
||||||
|
|
||||||
var handler = new HttpClientHandler
|
var handler = new HttpClientHandler
|
||||||
{
|
{
|
||||||
SslProtocols = SslProtocols.Tls12
|
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) =>
|
handler.ServerCertificateCustomValidationCallback = (request, cert, chain, errors) =>
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Reference in a new issue