Repository navigation
Conversation
Each HAProxy instance generates its own TLS ticket keys, and generates new ones on every reload. A client spread over several replicas, or reconnecting after a reload, cannot resume its session and pays a full handshake. tls-ticket-keys takes the path of a keys file, typically mounted from a Secret, and sets it on the v4, v6 and ssl-passthrough binds of the https frontend when SSL offload is enabled. Replicas sharing the file resume each other's sessions. The quic binds are left untouched. The path is ignored when the file cannot be read, since HAProxy would reject the configuration. It is applied after the ssl-passthrough toggle, which recreates the binds, and a reload is requested only when a bind changes. A rotated file is picked up on the next reload.
HAProxy reads the tls-ticket-keys file only when it starts or reloads, so a rotated Secret was applied at the next unrelated reload, and forcing one costs a reload per rotation. On every sync tick, the controller now checks whether the keys file changed. When it did, it compares the keys HAProxy holds (show tls-keys) with the last three lines of the file and pushes only the missing ones with set ssl tls-key, which appends a key and drops the oldest. A rotation that appended one key pushes that key, and one already loaded by a reload in between pushes nothing. A failed runtime update falls back to a reload, which reads the file again.
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.
Each HAProxy instance generates its own TLS ticket keys, and new ones on every reload. Behind several replicas (DNS round robin, a load balancer without affinity), a client that lands on another replica, or comes back after a reload, cannot resume its session and pays a full handshake.
This adds a
tls-ticket-keysConfigMap annotation holding the path of a keys file, typically mounted from a Secret:MEDIUM: ssl: add the tls-ticket-keys configmap annotation: setstls-ticket-keys <file>on the v4, v6 and ssl-passthrough binds of the https frontend when SSL offload is enabled. The quic binds are left untouched. An unreadable path is ignored, since HAProxy would reject the configuration. A reload is requested only when a bind changes.MEDIUM: ssl: rotate tls-ticket-keys through the runtime API: on every sync tick, when the file changed, the controller compares the loaded keys (show tls-keys) with the last three lines of the file and pushes only the missing ones withset ssl tls-key. A rotation therefore needs no reload. A failed runtime update falls back to a reload.The Frontend v3 custom resource has a
tls_ticket_keysfield, but the controller-owned binds win the merge, so it cannot set it on the https binds today.Tests
pkg/handler,pkg/controller).tls-ticket-keyson thev4andv6binds only;openssl s_client -sess_outon replica A then-sess_inon replica B:Reusedwith TLS 1.2 and 1.3,Newwithout the annotation;pushed a rotated keyin both controllers, no reload,show tls-keysmatching the new file, and a ticket issued before the rotation stillReusedon the other replica.