mirror of
https://github.com/bitwarden/server
synced 2026-01-07 11:03:37 +00:00
Remove X509ChainCustomization Feature (#6108)
* Remove X509ChainCustomization Feature * `dotnet format`
This commit is contained in:
@@ -1,13 +1,10 @@
|
||||
// FIXME: Update this file to be null safe and then delete the line below
|
||||
#nullable disable
|
||||
|
||||
using System.Security.Cryptography.X509Certificates;
|
||||
using Bit.Core.Platform.X509ChainCustomization;
|
||||
using Bit.Core.Settings;
|
||||
using Bit.Core.Utilities;
|
||||
using MailKit.Net.Smtp;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.Extensions.Options;
|
||||
using MimeKit;
|
||||
|
||||
namespace Bit.Core.Services;
|
||||
@@ -16,14 +13,12 @@ public class MailKitSmtpMailDeliveryService : IMailDeliveryService
|
||||
{
|
||||
private readonly GlobalSettings _globalSettings;
|
||||
private readonly ILogger<MailKitSmtpMailDeliveryService> _logger;
|
||||
private readonly X509ChainOptions _x509ChainOptions;
|
||||
private readonly string _replyDomain;
|
||||
private readonly string _replyEmail;
|
||||
|
||||
public MailKitSmtpMailDeliveryService(
|
||||
GlobalSettings globalSettings,
|
||||
ILogger<MailKitSmtpMailDeliveryService> logger,
|
||||
IOptions<X509ChainOptions> x509ChainOptions)
|
||||
ILogger<MailKitSmtpMailDeliveryService> logger)
|
||||
{
|
||||
if (globalSettings.Mail.Smtp?.Host == null)
|
||||
{
|
||||
@@ -44,7 +39,6 @@ public class MailKitSmtpMailDeliveryService : IMailDeliveryService
|
||||
|
||||
_globalSettings = globalSettings;
|
||||
_logger = logger;
|
||||
_x509ChainOptions = x509ChainOptions.Value;
|
||||
}
|
||||
|
||||
public async Task SendEmailAsync(Models.Mail.MailMessage message)
|
||||
@@ -89,13 +83,6 @@ public class MailKitSmtpMailDeliveryService : IMailDeliveryService
|
||||
{
|
||||
client.ServerCertificateValidationCallback = (s, c, h, e) => true;
|
||||
}
|
||||
else if (_x509ChainOptions.TryGetCustomRemoteCertificateValidationCallback(out var callback))
|
||||
{
|
||||
client.ServerCertificateValidationCallback = (sender, cert, chain, errors) =>
|
||||
{
|
||||
return callback(new X509Certificate2(cert), chain, errors);
|
||||
};
|
||||
}
|
||||
|
||||
if (!_globalSettings.Mail.Smtp.StartTls && !_globalSettings.Mail.Smtp.Ssl &&
|
||||
_globalSettings.Mail.Smtp.Port == 25)
|
||||
|
||||
Reference in New Issue
Block a user