diff --git a/src/GZCTF/Models/Internal/Configs.cs b/src/GZCTF/Models/Internal/Configs.cs index 72f38bac2..69516b3c7 100644 --- a/src/GZCTF/Models/Internal/Configs.cs +++ b/src/GZCTF/Models/Internal/Configs.cs @@ -226,6 +226,7 @@ public class SmtpConfig { public string? Host { get; set; } = "127.0.0.1"; public int? Port { get; set; } = 587; + public bool BypassCertVerify { get; set; } } public class EmailConfig diff --git a/src/GZCTF/Services/Mail/MailSender.cs b/src/GZCTF/Services/Mail/MailSender.cs index f973f9abd..fcb5b956d 100644 --- a/src/GZCTF/Services/Mail/MailSender.cs +++ b/src/GZCTF/Services/Mail/MailSender.cs @@ -47,6 +47,9 @@ public MailSender( !cipherName.EndsWith("NULL"); })); + _smtpClient.ServerCertificateValidationCallback = (_, _, _, errors) + => errors is SslPolicyErrors.None || options.Value.Smtp?.BypassCertVerify is true; + Task.Factory.StartNew(MailSenderWorker, _cancellationToken, TaskCreationOptions.LongRunning, TaskScheduler.Default); }