Skip to content

Avoid re-parsing openssl key material with non-cached provider (#16759)#16791

Merged
chrisvest merged 1 commit into
netty:4.1from
chrisvest:4.1-openssl-kmprov-cache
May 11, 2026
Merged

Avoid re-parsing openssl key material with non-cached provider (#16759)#16791
chrisvest merged 1 commit into
netty:4.1from
chrisvest:4.1-openssl-kmprov-cache

Conversation

@chrisvest
Copy link
Copy Markdown
Member

Motivation:
The non-caching OpenSslKeyMaterialProvider must check with the KeyManager on every handshake, if the certificate and keys have changed. However, if they haven't then it is a waste of cycles to allocate, serialize, and parse the key material on every handshake.

Modification:
Add a single-entry cache of the key material and do an identity on the key and certificates after the KeyManager look-up. If there's a match, we can reuse the key material we created earlier. Many systems, particularly internal web services, only have a single key and certificate pair, so the single-entry cache will be very effective there.

Result:
Speeds up TLS handshakes when a server is configured with a KeyManagerFactory or KeyManager, and the key/cert pair isn't changing on every handshake.

(cherry picked from commit edffed0)

…#16759)

Motivation:
The non-caching `OpenSslKeyMaterialProvider` must check with the
`KeyManager` on every handshake, if the certificate and keys have
changed. However, if they haven't then it is a waste of cycles to
allocate, serialize, and parse the key material on every handshake.

Modification:
Add a single-entry cache of the key material and do an identity on the
key and certificates after the `KeyManager` look-up. If there's a match,
we can reuse the key material we created earlier. Many systems,
particularly internal web services, only have a single key and
certificate pair, so the single-entry cache will be very effective
there.

Result:
Speeds up TLS handshakes when a server is configured with a
`KeyManagerFactory` or `KeyManager`, and the key/cert pair isn't
changing on every handshake.

(cherry picked from commit edffed0)
@chrisvest chrisvest added this to the 4.1.134.Final milestone May 11, 2026
@chrisvest chrisvest merged commit 25db4bb into netty:4.1 May 11, 2026
18 checks passed
@chrisvest chrisvest deleted the 4.1-openssl-kmprov-cache branch May 11, 2026 19:37
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