-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Fix DotNettySslSetup being ignored when HOCON has valid SSL config #7918
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Aaronontheweb
merged 2 commits into
akkadotnet:dev
from
Aaronontheweb:fix/dotnetty-ssl-setup-override-7917
Oct 22, 2025
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -195,6 +195,58 @@ public void Four_parameter_setup_should_configure_transport_settings_with_all_va | |
| Assert.True(settings.Ssl.ValidateCertificateHostname); // explicitly set to true | ||
| } | ||
|
|
||
| [Fact(DisplayName = "DotNettySslSetup should override HOCON certificate configuration (Bug #7917)")] | ||
| public void DotNettySslSetup_should_override_HOCON_certificate() | ||
| { | ||
| // This test exposes the bug where HOCON certificate wins over DotNettySslSetup | ||
| // when HOCON has valid certificate configuration | ||
|
|
||
| // HOCON certificate | ||
| const string hoconCertPath = "Resources/akka-validcert.pfx"; | ||
| var hoconCert = new X509Certificate2(hoconCertPath, Password, X509KeyStorageFlags.DefaultKeySet); | ||
|
|
||
| // Programmatic setup certificate (different from HOCON) | ||
| const string setupCertPath = "Resources/akka-client-cert.pfx"; | ||
| var setupCert = new X509Certificate2(setupCertPath, Password, X509KeyStorageFlags.DefaultKeySet); | ||
|
|
||
| var sslSetup = new DotNettySslSetup(setupCert, suppressValidation: true, requireMutualAuthentication: false, validateCertificateHostname: true); | ||
|
|
||
| var actorSystemSetup = ActorSystemSetup.Empty | ||
| .And(BootstrapSetup.Create().WithConfig(ConfigurationFactory.ParseString($@" | ||
| akka {{ | ||
| actor.provider = ""Akka.Remote.RemoteActorRefProvider,Akka.Remote"" | ||
| remote.dot-netty.tcp {{ | ||
| port = 0 | ||
| hostname = ""127.0.0.1"" | ||
| enable-ssl = true | ||
| ssl {{ | ||
| certificate {{ | ||
| path = ""{hoconCertPath}"" | ||
| password = ""{Password}"" | ||
| }} | ||
| suppress-validation = false | ||
| require-mutual-authentication = true | ||
| validate-certificate-hostname = false | ||
| }} | ||
| }} | ||
| }}"))) | ||
| .And(sslSetup); | ||
|
|
||
| using var sys = ActorSystem.Create("test", actorSystemSetup); | ||
|
|
||
| // Verify that DotNettyTransportSettings.Create uses the setup correctly | ||
| var settings = DotNettyTransportSettings.Create(sys); | ||
|
|
||
| Assert.True(settings.EnableSsl); | ||
|
|
||
| // BUG: DotNettySslSetup should take precedence over HOCON, but currently HOCON wins | ||
| // because CreateOrDefault tries HOCON first, and only uses the setup as an exception fallback | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This assertion failed before our fix. |
||
| Assert.Equal(setupCert.Thumbprint, settings.Ssl.Certificate.Thumbprint); // Should be setupCert, not hoconCert | ||
| Assert.True(settings.Ssl.SuppressValidation); // From DotNettySslSetup | ||
| Assert.False(settings.Ssl.RequireMutualAuthentication); // From DotNettySslSetup, not HOCON | ||
| Assert.True(settings.Ssl.ValidateCertificateHostname); // From DotNettySslSetup, not HOCON | ||
| } | ||
|
|
||
| #region helper classes / methods | ||
|
|
||
| protected override void AfterAll() | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -203,7 +203,7 @@ public static DotNettyTransportSettings Create(Config config, SslSettings? sslSe | |
| ServerSocketWorkerPoolSize: ComputeWorkerPoolSize(config.GetConfig("server-socket-worker-pool")), | ||
| ClientSocketWorkerPoolSize: ComputeWorkerPoolSize(config.GetConfig("client-socket-worker-pool")), | ||
| MaxFrameSize: ToNullableInt(config.GetByteSize("maximum-frame-size", null)) ?? 128000, | ||
| Ssl: enableSsl ? SslSettings.CreateOrDefault(config.GetConfig("ssl"), sslSettings) : SslSettings.Empty, | ||
| Ssl: enableSsl ? (sslSettings ?? SslSettings.Create(config.GetConfig("ssl"))) : SslSettings.Empty, | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Deprioritizes the default HOCON, in favor of what' specified in the |
||
| DnsUseIpv6: config.GetBoolean("dns-use-ipv6"), | ||
| TcpReuseAddr: ResolveTcpReuseAddrOption(config.GetString("tcp-reuse-addr", "off-for-windows")), | ||
| TcpKeepAlive: config.GetBoolean("tcp-keepalive", true), | ||
|
|
@@ -266,7 +266,7 @@ public static SslSettings CreateOrDefault(Config config, SslSettings? @default = | |
| } | ||
| } | ||
|
|
||
| private static SslSettings Create(Config config) | ||
| internal static SslSettings Create(Config config) | ||
| { | ||
| if (config.IsNullOrEmpty()) | ||
| throw new ConfigurationException($"Failed to create {typeof(DotNettyTransportSettings)}: DotNetty SSL HOCON config was not found (default path: `akka.remote.dot-netty.tcp.ssl`)"); | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use two different certs - validate that the setup overrides the HOCON