Skip to content

Conversation

@Aaronontheweb
Copy link
Member

Cherry-pick of #7918 to v1.5 branch

…kkadotnet#7918)

* Add failing test to expose DotNettySslSetup override bug (akkadotnet#7917)

Added test case that demonstrates DotNettySslSetup settings being ignored
when HOCON has valid certificate configuration. The test configures:

- HOCON with valid certificate path and settings
- DotNettySslSetup with different certificate and settings

Expected: DotNettySslSetup should take precedence (programmatic over config)
Actual: HOCON certificate is used, DotNettySslSetup is completely ignored

The bug occurs because CreateOrDefault() tries HOCON first and only uses
the programmatic setup as an exception fallback. This test fails and
will pass once the fix is applied to make programmatic setup take precedence.

Existing tests didn't catch this because they only test the exception-based
fallback path (HOCON with enable-ssl=true but no certificate path).

* Fix DotNettySslSetup being ignored when HOCON has valid SSL config (akkadotnet#7917)

Changed SSL settings initialization to prioritize programmatic DotNettySslSetup
over HOCON configuration, fixing the precedence order bug.

Changes:
- Modified DotNettyTransportSettings.Create() to check sslSettings (from
  DotNettySslSetup) first before parsing HOCON configuration
- Changed SslSettings.Create() from private to internal to enable direct usage
- Previous behavior: HOCON always tried first, programmatic setup only used
  as exception fallback
- New behavior: Programmatic setup takes precedence, HOCON used if not provided

This ensures programmatic configuration properly overrides HOCON defaults,
which is the expected behavior for Setup-based configuration in Akka.NET.

The bug existed since DotNettySslSetup was introduced in July 2023
(commit 588d5d6). Existing tests passed only because they triggered
the exception-based fallback path (HOCON with enable-ssl=true but no
certificate path).
@Aaronontheweb Aaronontheweb merged commit 1e8d606 into akkadotnet:v1.5 Oct 22, 2025
6 of 11 checks passed
@Aaronontheweb Aaronontheweb deleted the feature/dotnetty-ssl-setup-fix branch October 22, 2025 21:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant