From 665ae0cf2464311061bedf30ad60680586ebefd9 Mon Sep 17 00:00:00 2001 From: Justin Baur <19896123+justindbaur@users.noreply.github.com> Date: Fri, 4 Apr 2025 12:08:52 -0400 Subject: [PATCH] Fix places I am still calling it TLS options --- ...ustomizationServiceCollectionExtensions.cs | 10 +++++----- .../MailKitSmtpMailDeliveryService.cs | 8 ++++---- .../MailKitSmtpMailDeliveryServiceTests.cs | 20 +++++++++---------- ...izationServiceCollectionExtensionsTests.cs | 2 +- 4 files changed, 20 insertions(+), 20 deletions(-) diff --git a/src/Core/Platform/X509ChainCustomization/X509ChainCustomizationServiceCollectionExtensions.cs b/src/Core/Platform/X509ChainCustomization/X509ChainCustomizationServiceCollectionExtensions.cs index 45de2c5460..780bf70f7f 100644 --- a/src/Core/Platform/X509ChainCustomization/X509ChainCustomizationServiceCollectionExtensions.cs +++ b/src/Core/Platform/X509ChainCustomization/X509ChainCustomizationServiceCollectionExtensions.cs @@ -5,12 +5,12 @@ using Microsoft.Extensions.DependencyInjection.Extensions; namespace Microsoft.Extensions.DependencyInjection; /// -/// Extension methods for setting up the ability to provide customization to how TLS works in an . +/// Extension methods for setting up the ability to provide customization to how X509 chain validation works in an . /// public static class X509ChainCustomizationServiceCollectionExtensions { /// - /// Configures X509ChainPolicy customization through the root level TlsOptions configuration section + /// Configures X509ChainPolicy customization through the root level X509ChainOptions configuration section /// and configures the primary to use custom certificate validation /// when customized to do so. /// @@ -23,7 +23,7 @@ public static class X509ChainCustomizationServiceCollectionExtensions services.AddOptions() .BindConfiguration(nameof(X509ChainOptions)); - // Use TryAddEnumerable to make sure `PostConfigureTlsOptions` isn't added multiple + // Use TryAddEnumerable to make sure `PostConfigureX509ChainOptions` isn't added multiple // times even if this method is called multiple times. services.TryAddEnumerable(ServiceDescriptor.Singleton, PostConfigureX509ChainOptions>()); @@ -32,11 +32,11 @@ public static class X509ChainCustomizationServiceCollectionExtensions { builder.ConfigurePrimaryHttpMessageHandler(sp => { - var tlsOptions = sp.GetRequiredService>().Value; + var x509ChainOptions = sp.GetRequiredService>().Value; var handler = new HttpClientHandler(); - if (tlsOptions.TryGetCustomRemoteCertificateValidationCallback(out var callback)) + if (x509ChainOptions.TryGetCustomRemoteCertificateValidationCallback(out var callback)) { handler.ServerCertificateCustomValidationCallback = (sender, certificate, chain, errors) => { diff --git a/src/Core/Services/Implementations/MailKitSmtpMailDeliveryService.cs b/src/Core/Services/Implementations/MailKitSmtpMailDeliveryService.cs index f9a6762772..3a7cabd39e 100644 --- a/src/Core/Services/Implementations/MailKitSmtpMailDeliveryService.cs +++ b/src/Core/Services/Implementations/MailKitSmtpMailDeliveryService.cs @@ -13,14 +13,14 @@ public class MailKitSmtpMailDeliveryService : IMailDeliveryService { private readonly GlobalSettings _globalSettings; private readonly ILogger _logger; - private readonly X509ChainOptions _x509CertificateCustomization; + private readonly X509ChainOptions _x509ChainOptions; private readonly string _replyDomain; private readonly string _replyEmail; public MailKitSmtpMailDeliveryService( GlobalSettings globalSettings, ILogger logger, - IOptions tlsOptions) + IOptions x509ChainOptions) { if (globalSettings.Mail?.Smtp?.Host == null) { @@ -36,7 +36,7 @@ public class MailKitSmtpMailDeliveryService : IMailDeliveryService _globalSettings = globalSettings; _logger = logger; - _x509CertificateCustomization = tlsOptions.Value; + _x509ChainOptions = x509ChainOptions.Value; } public async Task SendEmailAsync(Models.Mail.MailMessage message) @@ -81,7 +81,7 @@ public class MailKitSmtpMailDeliveryService : IMailDeliveryService { client.ServerCertificateValidationCallback = (s, c, h, e) => true; } - else if (_x509CertificateCustomization.TryGetCustomRemoteCertificateValidationCallback(out var callback)) + else if (_x509ChainOptions.TryGetCustomRemoteCertificateValidationCallback(out var callback)) { client.ServerCertificateValidationCallback = (sender, cert, chain, errors) => { diff --git a/test/Core.IntegrationTest/MailKitSmtpMailDeliveryServiceTests.cs b/test/Core.IntegrationTest/MailKitSmtpMailDeliveryServiceTests.cs index 7914a6d147..8668263fa4 100644 --- a/test/Core.IntegrationTest/MailKitSmtpMailDeliveryServiceTests.cs +++ b/test/Core.IntegrationTest/MailKitSmtpMailDeliveryServiceTests.cs @@ -1,9 +1,9 @@ using System.Security.Cryptography; using System.Security.Cryptography.X509Certificates; using Bit.Core.Models.Mail; +using Bit.Core.Platform.X509ChainCustomization; using Bit.Core.Services; using Bit.Core.Settings; -using Bit.Core.Platform.TlsCustomization; using MailKit.Security; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging.Abstractions; @@ -103,7 +103,7 @@ public class MailKitSmtpMailDeliveryServiceTests var mailKitDeliveryService = new MailKitSmtpMailDeliveryService( globalSettings, NullLogger.Instance, - Options.Create(new X509CertificateCustomizationOptions()) + Options.Create(new X509ChainOptions()) ); await Assert.ThrowsAsync( @@ -133,7 +133,7 @@ public class MailKitSmtpMailDeliveryServiceTests gs.Mail.Smtp.Ssl = true; }); - var tlsOptions = new X509CertificateCustomizationOptions + var x509ChainOptions = new X509ChainOptions { AdditionalCustomTrustCertificates = [ @@ -144,7 +144,7 @@ public class MailKitSmtpMailDeliveryServiceTests var mailKitDeliveryService = new MailKitSmtpMailDeliveryService( globalSettings, NullLogger.Instance, - Options.Create(tlsOptions) + Options.Create(x509ChainOptions) ); var tcs = new TaskCompletionSource(); @@ -188,7 +188,7 @@ public class MailKitSmtpMailDeliveryServiceTests gs.Mail.Smtp.Ssl = true; }); - var tlsOptions = new X509CertificateCustomizationOptions + var x509ChainOptions = new X509ChainOptions { AdditionalCustomTrustCertificates = [ @@ -200,7 +200,7 @@ public class MailKitSmtpMailDeliveryServiceTests var mailKitDeliveryService = new MailKitSmtpMailDeliveryService( globalSettings, NullLogger.Instance, - Options.Create(tlsOptions) + Options.Create(x509ChainOptions) ); var tcs = new TaskCompletionSource(); @@ -248,7 +248,7 @@ public class MailKitSmtpMailDeliveryServiceTests var mailKitDeliveryService = new MailKitSmtpMailDeliveryService( globalSettings, NullLogger.Instance, - Options.Create(new X509CertificateCustomizationOptions()) + Options.Create(new X509ChainOptions()) ); var tcs = new TaskCompletionSource(); @@ -295,7 +295,7 @@ public class MailKitSmtpMailDeliveryServiceTests var mailKitDeliveryService = new MailKitSmtpMailDeliveryService( globalSettings, NullLogger.Instance, - Options.Create(new X509CertificateCustomizationOptions()) + Options.Create(new X509ChainOptions()) ); var cts = new CancellationTokenSource(TimeSpan.FromSeconds(5)); @@ -331,7 +331,7 @@ public class MailKitSmtpMailDeliveryServiceTests var mailKitDeliveryService = new MailKitSmtpMailDeliveryService( globalSettings, NullLogger.Instance, - Options.Create(new X509CertificateCustomizationOptions()) + Options.Create(new X509ChainOptions()) ); var tcs = new TaskCompletionSource(); @@ -398,7 +398,7 @@ public class MailKitSmtpMailDeliveryServiceTests var mailKitDeliveryService = new MailKitSmtpMailDeliveryService( globalSettings, NullLogger.Instance, - Options.Create(new X509CertificateCustomizationOptions()) + Options.Create(new X509ChainOptions()) ); var tcs = new TaskCompletionSource(); diff --git a/test/Core.Test/Platform/X509ChainCustomization/X509ChainCustomizationServiceCollectionExtensionsTests.cs b/test/Core.Test/Platform/X509ChainCustomization/X509ChainCustomizationServiceCollectionExtensionsTests.cs index 2af9b7cc8a..30eb19d8c0 100644 --- a/test/Core.Test/Platform/X509ChainCustomization/X509ChainCustomizationServiceCollectionExtensionsTests.cs +++ b/test/Core.Test/Platform/X509ChainCustomization/X509ChainCustomizationServiceCollectionExtensionsTests.cs @@ -9,7 +9,7 @@ using Microsoft.Extensions.Options; using NSubstitute; using Xunit; -namespace Bit.Core.Test.Platform.TlsCustomization; +namespace Bit.Core.Test.Platform.X509ChainCustomization; public class X509ChainCustomizationServiceCollectionExtensionsTests {