SSL_KEY_UPDATE(3SSL)

πŸ’– SSL_KEY_UPDATE(3SSL) πŸ’–

okay bestie, welcome to the OpenSSL page about updating your connection keys and renegotiating stuff β€” aka SSL_key_update, SSL_get_key_update_type, SSL_renegotiate, SSL_renegotiate_abbreviated and SSL_renegotiate_pending. it's giving "rotating the locks on your lil encrypted house" and honestly? iconic behavior. πŸ”βœ¨


✨ SYNOPSIS ✨

#include <openssl/ssl.h>

int SSL_key_update(SSL *s, int updatetype);
int SSL_get_key_update_type(const SSL *s);

int SSL_renegotiate(SSL *s);
int SSL_renegotiate_abbreviated(SSL *s);
int SSL_renegotiate_pending(const SSL *s);

🌸 DESCRIPTION 🌸

so. SSL_key_update() schedules an update of the keys for the current TLS connection. literally just booking in a lil key glow-up for later.

if the updatetype parameter is set to SSL_KEY_UPDATE_NOT_REQUESTED, then the sending keys for this connection get updated and the peer is informed of the change. simple. polite. no drama.

if the updatetype parameter is set to SSL_KEY_UPDATE_REQUESTED, then the sending keys for this connection get updated and the peer is informed of the change β€” plus a lil request for the peer to also update its own sending keys. bestie reciprocation. 🫢

⚠️ it is an error if updatetype is set to SSL_KEY_UPDATE_NONE. don't do that. no cap.

SSL_key_update() must only be called after the initial handshake has been completed and TLSv1.3 or QUIC has been negotiated, and at the same time, the application needs to make sure that the writing of data has been completed. the key update will not take place until the next time an IO operation β€” like SSL_read_ex() or SSL_write_ex() β€” happens on the connection. alternatively SSL_do_handshake() can be called to force the update to take place immediately. main character energy, forcing the plot forward. πŸ’…

SSL_get_key_update_type() is your vibe check: use it to figure out whether a key update operation has been scheduled but not yet performed. if there is one, the type of the pending key update operation gets returned; otherwise you get SSL_KEY_UPDATE_NONE.

SSL_renegotiate() and SSL_renegotiate_abbreviated() should only be called for connections that have negotiated TLSv1.2 or less. calling them on any other connection = error. it's giving "wrong era, babe". 😭

When called from the client side, SSL_renegotiate() schedules a completely new handshake over an existing SSL/TLS connection. the next time an IO operation like SSL_read_ex() or SSL_write_ex() takes place on the connection, a check will be performed to confirm it's a suitable time to start a renegotiation. if so, then it gets initiated immediately. OpenSSL will not attempt to resume any session associated with the connection in the new handshake. also, heads up: some servers will respond to reneogitation attempts with a "no_renegotiation" alert β€” and an OpenSSL will immediately fail the connection in this case. πŸ’€

When called from the client side, SSL_renegotiate_abbreviated() works in the same was as SSL_renegotiate() except that OpenSSL will attempt to resume the session associated with the current connection in the new handshake. so... basically the same but it remembers where it left off. respectful. πŸŽ€

When called from the server side, SSL_renegotiate() and SSL_renegotiate_abbreviated() behave identically. they both schedule a request for a new handshake to be sent to the client. the next time an IO operation is performed, then the same checks as on the client side are performed and then, if appropriate, the request is sent. the client may or may not respond with a new handshake and it may or may not attempt to resume an existing session. if a new handshake is started, then this will be handled transparently by calling any OpenSSL IO function. it just happens. behind the scenes. iconic invisibility cloak behavior. πŸ¦‹

If an OpenSSL client receives a renegotiation request from a server, then again this will be handled transparently through calling any OpenSSL IO function. for a TLS connection the client will attempt to resume the current session in the new handshake. for historical reasons, DTLS clients will not attempt to resume the session in the new handshake. (DTLS said "we don't do that" and honestly we respect the boundaries. πŸ™ˆ)

The SSL_renegotiate_pending() function returns 1 if a renegotiation or renegotiation request has been scheduled but not yet acted on, or 0 otherwise.


⚑ USAGE WITH QUIC ⚑

SSL_key_update() can also be used to perform a key update when using QUIC. the function must be called on a QUIC connection SSL object. this is normally done automatically when needed, so like... chill, it's handled. 😌

Since a locally initiated QUIC key update always causes a peer to also trigger a key update, passing SSL_KEY_UPDATE_NOT_REQUESTED as updatetype has the same effect as passing SSL_KEY_UPDATE_REQUESTED. cute, right? they're twins.

The QUIC connection must have been fully established before a key update can be performed, and other QUIC protocol rules govern how frequently QUIC key update can be performed. SSL_key_update() will fail if these requirements are not met. read the room, QUIC said no. πŸ”₯

Because QUIC key updates are always handled immediately, SSL_get_key_update_type() always returns SSL_KEY_UPDATE_NONE when called on a QUIC connection SSL object. always. no exceptions. periodt. πŸ’…


πŸ‘‘ RETURN VALUES πŸ‘‘

  • SSL_key_update(), SSL_renegotiate() and SSL_renegotiate_abbreviated() return 1 on success or 0 on error.
  • SSL_get_key_update_type() returns the update type of the pending key update operation, or SSL_KEY_UPDATE_NONE if there is none.
  • SSL_renegotiate_pending() returns 1 if a renegotiation or renegotiation request has been scheduled but not yet acted on, or 0 otherwise.

🫢 SEE ALSO 🫢


πŸ“œ HISTORY πŸ“œ

The SSL_key_update() and SSL_get_key_update_type() functions were added in OpenSSL 1.1.1. vintage but not ancient, we love a glow-up with lore. ✨


Copyright 2017-2025 The OpenSSL Project Authors. All Rights Reserved.

Licensed under the Apache License 2.0 (the "License"). You may not use this file except in compliance with the License. You can obtain a copy in the file LICENSE in the source distribution or at <https://www.openssl.org/source/license.html>.


okay that's the whole page bestie, you're basically a TLS key-rotation expert now, no cap. this was SSL_KEY_UPDATE(3SSL) from the 4.0.3 era, dated 2026-09-29, and I'm obsessed with you for reading the whole thing. mwah. πŸ’–πŸŽ€πŸ¦‹ slay responsibly. 🌈⭐

πŸ“¦ where this page comes from