Repository navigation
Rotate Akka.Remote TLS certificates without a restart (Akka.NET 1.5.75 beta trial) - #305
Draft
Aaronontheweb wants to merge 2 commits into
Draft
Aaronontheweb wants to merge 2 commits into
Aaronontheweb wants to merge 2 commits into
Conversation
Points AkkaVersion and AkkaHostingVersion at 1.5.75-beta-1794596265, which adds TlsCertificateSource for Akka.Remote's DotNetty transport.
When AkkaSettings:TlsSettings:CertificatePath names a folder, use TlsCertificateSource.FromFolder so each node picks the newest usable certificate in it and new connections use it with no restart. A single file still loads once at startup, as before. The Aspire path now applies the same TLS settings on top of the Akka.Aspire plugin's remoting set-up, which otherwise ignores them. The Aspire host gains DrawTogether:TlsCertificatePath and DrawTogether:TlsCertificatePassword (off by default) to try this locally. generate-certs.ps1 now adds client authentication to the extended key usage: with mutual TLS a folder rejects a server-only certificate. certs/README.md shows how to try a rotation with two certificates.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Draft, for review only. CI cannot pass yet. This branch pins Akka.NET to
1.5.75-beta-1794596265, which exists only on the private test lab feed. The feed is left out of this pull request on purpose, so the diff reads as what an application developer would change. The Akka.NET side is akkadotnet/akka.net#8959, akkadotnet/akka.net#8960 and akkadotnet/akka.net#8961.What changed
AkkaSettings:TlsSettings:CertificatePathmay now name a folder. Each node then uses the newest usable.pfxin it (latest start date) for new connections. Copy a renewed certificate in and the nodes pick it up within about a minute, with no restart. A single file still works as before.TlsSettingswere ignored there, so the cluster ran without TLS under Aspire.DrawTogether:TlsCertificatePathandDrawTogether:TlsCertificatePassword. Both are off by default.generate-certs.ps1now adds client authentication to the certificate. With mutual TLS, a folder rejects a certificate that only allows server authentication, such as the committedcerts/akka-node.pfx.certs/README.mdhas a new section on rotating between two certificates.The app change is
BuildSslOptionsinAkkaConfiguration.cs: when the path is a folder it setsSsl.CertificateSource = TlsCertificateSource.FromFolder(path, password); otherwise it loads one file as before.Try it locally
opensslas shown incerts/README.md(serverAuth + clientAuth, one shared password). Put onlycert-a.pfxin a folder.dotnet run --project src/DrawTogether.AppHost -- --DrawTogether:TlsCertificatePath=<folder> --DrawTogether:TlsCertificatePassword='Test123!' --DrawTogether:Replicas=3cp cert-b.pfx <folder>/.What you will see
TLS client and server certificate changed from none to <A thumbprint> (subject 'CN=DrawTogether.Akka.Remote', expires …), and node addresses useakka.ssl.tcp://.… changed from <A> (…) to <B> (…).openssl s_client -connect localhost:<remoting port> </dev/null 2>/dev/null | openssl x509 -noout -fingerprint -sha1shows B on new connections. Each probe like this logs a handshake error on the node, because the probe sends no client certificate.TLS certificate skipped: …warning, and the node keeps its current certificate.What the trial run showed
Run locally under Aspire with 3 replicas, Redis discovery and SQL Server.
cp).pfxwith the wrong passwordThrough all of it: no node marked unreachable, no failed node-to-node handshake, no shutdown.
Found along the way
certs/akka-node.pfxdoes not work in a folder. It allows server authentication only. As a single file it is still accepted; in a folder every node fails to start withits enhanced key usage does not permit client authentication. Regenerate it with the updated script before pointing the Kubernetes manifests at a folder.statefulset.yamlalready mounts the wholeakka-tls-certsecret at/certs, so the change is to setAkkaSettings__TlsSettings__CertificatePathto/certsand give the secret one key per certificate.deploy.ps1deletes and recreates the secret today; a renewal should update it in place.Not tested
PEM files, the store and callback sources, peer validation on (
ValidateCertificates = true), and the end-to-end test suite.