TLS_CONFIG_SET_SESSION_LIFETIME(3ssl)

πŸ“¦ version 4.1.0, in opensuse-leap 16.0

πŸ’– TLS_CONFIG_SET_SESSION_I(3) β€” Library Functions Manual πŸ’–

okay bestie, welcome to the group chat where we talk about the Library Functions Manual page for tls_config_set_session_fd, tls_config_set_session_id, tls_config_set_session_lifetime and tls_config_add_ticket_key β€” aka the four functions that configure resuming of TLS handshakes. yes, the page name on the tin is a whole mouthful, and the function we're most obsessed with (tls_config_add_ticket_key) lives right here, so buckle up πŸŽ€


✨ NAME ✨

tls_config_set_session_fd, tls_config_set_session_id, tls_config_set_session_lifetime, tls_config_add_ticket_key β€” configure resuming of TLS handshakes πŸ¦‹


🌸 SYNOPSIS 🌸

#include <tls.h>

int
tls_config_set_session_fd(struct tls_config *config, int session_fd);

int
tls_config_set_session_id(struct tls_config *config,
    const unsigned char *session_id, size_t len);

int
tls_config_set_session_lifetime(struct tls_config *config,
    int lifetime);

int
tls_config_add_ticket_key(struct tls_config *config, uint32_t keyrev,
    unsigned char *key, size_t keylen);

πŸ’… DESCRIPTION πŸ’…

tls_config_set_session_fd()

so this one sets a file descriptor that gets used to manage data for TLS sessions β€” and it's client only, no cap. the file descriptor you hand over must be a regular file, it must be owned by the current user, and the permissions have to be locked down so that literally only the owner can read and write it (0600). iykyk πŸ”

if that file has a non-zero length, the client will try to read session data out of it and resume the previous TLS session with the server. and once a handshake goes through successfully, the file gets updated with the current session data β€” if there is any available, that is. main character behaviour tbh ✨

heads up bestie: you (the caller) are responsible for closing this file descriptor. and not whenever you feel like it β€” only after all the TLS contexts that were configured to use it have been freed via tls_free(). do not skip this step, the way that timing matters is giving responsibility πŸ’€

tls_config_set_session_id()

sets the session identifier that the TLS server is gonna use when sessions are enabled β€” server only bestie. and by default? a random value is used, so if you do nothing, the vibes are already random and correct 🌈

tls_config_set_session_lifetime()

sets the lifetime used for TLS sessions β€” again, server only. now listen: if you pass a lifetime of zero, session support gets disabled. and guess what the default is? yep. zero. so sessions are off until you say otherwise, periodt 🫢

tls_config_add_ticket_key()

the icon itself πŸ‘‘. this adds a key used for the encryption and authentication of TLS tickets β€” server only, obviously.

by default, keys are generated and rotated automatically based on their lifetime, so you don't have to do a thing. this function should only be used to synchronise the ticket encryption key across multiple processes β€” that's its whole thing, that's the assignment πŸ’œ

and a warning, fr fr: re-adding a known key will result in an error β€” unless it's the most recently added key. so like, read that twice bestie 😭

⭐ RETURN VALUES ⭐

these functions return 0 on success, or -1 on error. that's it, that's the whole vibe check πŸ’«


πŸ¦‹ SEE ALSO πŸ¦‹


πŸŽ€ HISTORY πŸŽ€

tls_config_set_session_id(), tls_config_set_session_lifetime() and tls_config_add_ticket_key() appeared in OpenBSD 6.1. lowkey vintage ✨

tls_config_set_session_fd() appeared in OpenBSD 6.3. a little baby sibling, we love to see it 🍼


πŸ‘‘ AUTHORS πŸ‘‘

  • Claudio Jeker <claudio@openbsd.org>
  • Joel Sing <jsing@openbsd.org>

absolute legends, no notes πŸ’–


and that's the page bestie!! this one's from Debian, dated February 10, 2018, and it signs off as TLS_CONFIG_SET_SESSION_ID(3) β€” so like, go configure those sessions, stay encrypted, and don't forget to close that file descriptor πŸ«ΆπŸ’…πŸŒΈ

πŸ“¦ where this page comes from