mirror of
https://github.com/btcpayserver/btcpayserver.git
synced 2024-11-19 09:54:30 +01:00
Do not check certificates for SMTP settings if local server
This commit is contained in:
parent
0dcfbe8581
commit
db1a124ffb
@ -676,10 +676,10 @@ namespace BTCPayServer.Tests
|
|||||||
response = await client.GetAsync("http://explorerzydxu5ecjrkwceayqybizmpjjznk5izmitf2modhcusuqlid.onion/");
|
response = await client.GetAsync("http://explorerzydxu5ecjrkwceayqybizmpjjznk5izmitf2modhcusuqlid.onion/");
|
||||||
response.EnsureSuccessStatusCode();
|
response.EnsureSuccessStatusCode();
|
||||||
|
|
||||||
TestLogs.LogInformation("Querying an onion address which can't be found should send http 500");
|
TestLogs.LogInformation("Querying an onion address which can't be found");
|
||||||
await Assert.ThrowsAsync<HttpRequestException>(() => client.GetAsync("http://dwoduwoi.onion/"));
|
await Assert.ThrowsAsync<HttpRequestException>(() => client.GetAsync("http://dwoduwoi.onion/"));
|
||||||
|
|
||||||
TestLogs.LogInformation("Querying valid onion but unreachable should send error 502");
|
TestLogs.LogInformation("Querying valid onion but unreachable");
|
||||||
await Assert.ThrowsAsync<HttpRequestException>(() => client.GetAsync("http://nzwsosflsoquxirwb2zikz6uxr3u5n5u73l33umtdx4hq5mzm5dycuqd.onion/"));
|
await Assert.ThrowsAsync<HttpRequestException>(() => client.GetAsync("http://nzwsosflsoquxirwb2zikz6uxr3u5n5u73l33umtdx4hq5mzm5dycuqd.onion/"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,8 @@ using MailKit.Net.Smtp;
|
|||||||
using MimeKit;
|
using MimeKit;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
|
using System.Net.Security;
|
||||||
|
using System.Security.Cryptography.X509Certificates;
|
||||||
|
|
||||||
namespace BTCPayServer.Services.Mails
|
namespace BTCPayServer.Services.Mails
|
||||||
{
|
{
|
||||||
@ -77,6 +79,13 @@ namespace BTCPayServer.Services.Mails
|
|||||||
using var connectCancel = new CancellationTokenSource(10000);
|
using var connectCancel = new CancellationTokenSource(10000);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
if (Extensions.IsLocalNetwork(Server))
|
||||||
|
{
|
||||||
|
client.CheckCertificateRevocation = false;
|
||||||
|
#pragma warning disable CA5359 // Do Not Disable Certificate Validation
|
||||||
|
client.ServerCertificateValidationCallback = (s, c, h, e) => true;
|
||||||
|
#pragma warning restore CA5359 // Do Not Disable Certificate Validation
|
||||||
|
}
|
||||||
await client.ConnectAsync(Server, Port.Value, MailKit.Security.SecureSocketOptions.Auto, connectCancel.Token);
|
await client.ConnectAsync(Server, Port.Value, MailKit.Security.SecureSocketOptions.Auto, connectCancel.Token);
|
||||||
await client.AuthenticateAsync(Login, Password, connectCancel.Token);
|
await client.AuthenticateAsync(Login, Password, connectCancel.Token);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user