Skip to content

Commit

Permalink
feat: allow bypassing certificate verification for SMTP
Browse files Browse the repository at this point in the history
  • Loading branch information
hez2010 committed Aug 30, 2024
1 parent 799b78a commit 1d49ed5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/GZCTF/Models/Internal/Configs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions src/GZCTF/Services/Mail/MailSender.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down

0 comments on commit 1d49ed5

Please sign in to comment.