SSL_CTX_SET_TLSEXT_USE_SRTP(3ossl)

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

πŸ’… SSL_CTX_set_tlsext_use_srtp(3ossl) β€” the OpenSSL manual, but make it make sense πŸŽ€

okay bestie, so this is the OpenSSL manual page for SSL_CTX_set_tlsext_use_srtp(3ossl) and the whole vibe is: how do we get SRTP (secure media, yk) working over DTLS, and how do we read back what got negotiated. it's giving "niche but iconic." let's go πŸ¦‹


✨ NAME ✨

SSL_CTX_set_tlsext_use_srtp, SSL_set_tlsext_use_srtp, SSL_get_srtp_profiles, SSL_get_selected_srtp_profile β€” configure and query SRTP support, no cap πŸ’…


🌸 SYNOPSIS 🌸

#include <openssl/srtp.h>

int SSL_CTX_set_tlsext_use_srtp(SSL_CTX *ctx, const char *profiles);
int SSL_set_tlsext_use_srtp(SSL *ssl, const char *profiles);

STACK_OF(SRTP_PROTECTION_PROFILE) *SSL_get_srtp_profiles(SSL *ssl);
SRTP_PROTECTION_PROFILE *SSL_get_selected_srtp_profile(SSL *s);

πŸŽ€ DESCRIPTION πŸŽ€

okay so first things first: SRTP is the Secure Real-Time Transport Protocol. OpenSSL implements support for the "use_srtp" DTLS extension defined in RFC5764 β€” that's the whole point of this page, bestie.

What it actually does: it's a mechanism for establishing SRTP keying material, algorithms and parameters using DTLS. You might use this as part of an implementation that conforms to RFC5763. ⭐

🫢 lowkey important: OpenSSL does not implement SRTP itself, and it does not implement RFC5763. Also, OpenSSL does not support the use of SRTP Master Key Identifiers (MKIs). And the extension is only supported in DTLS β€” any SRTP configuration will be totally ignored if a TLS connection is attempted. πŸ’€

πŸ¦‹ the client side

An OpenSSL client that wants to send the "use_srtp" extension should call SSL_CTX_set_tlsext_use_srtp() to set its use for all SSL objects subsequently created from an SSL_CTX. Alternatively, a client may call SSL_set_tlsext_use_srtp() to set its use for one individual SSL object. main character energy, choose your scope πŸ’…

The profiles parameter should point to a NUL-terminated, colon delimited list of SRTP protection profile names. (colon-delimited. please. not commas. πŸ™ˆ)

🌈 the currently supported protection profile names

  • SRTP_AES128_CM_SHA1_80 β€” this corresponds to SRTP_AES128_CM_HMAC_SHA1_80 defined in RFC5764.
  • SRTP_AES128_CM_SHA1_32 β€” this corresponds to SRTP_AES128_CM_HMAC_SHA1_32 defined in RFC5764.
  • SRTP_AEAD_AES_128_GCM β€” this corresponds to the profile of the same name defined in RFC7714.
  • SRTP_AEAD_AES_256_GCM β€” this corresponds to the profile of the same name defined in RFC7714.
  • SRTP_DOUBLE_AEAD_AES_128_GCM_AEAD_AES_128_GCM β€” this corresponds to the profile of the same name defined in RFC8723.
  • SRTP_DOUBLE_AEAD_AES_256_GCM_AEAD_AES_256_GCM β€” this corresponds to the profile of the same name defined in RFC8723.
  • SRTP_ARIA_128_CTR_HMAC_SHA1_80 β€” this corresponds to the profile of the same name defined in RFC8269.
  • SRTP_ARIA_128_CTR_HMAC_SHA1_32 β€” this corresponds to the profile of the same name defined in RFC8269.
  • SRTP_ARIA_256_CTR_HMAC_SHA1_80 β€” this corresponds to the profile of the same name defined in RFC8269.
  • SRTP_ARIA_256_CTR_HMAC_SHA1_32 β€” this corresponds to the profile of the same name defined in RFC8269.
  • SRTP_AEAD_ARIA_128_GCM β€” this corresponds to the profile of the same name defined in RFC8269.
  • SRTP_AEAD_ARIA_256_GCM β€” this corresponds to the profile of the same name defined in RFC8269.
🚨 Supplying an unrecognised protection profile name will result in an error. periodt.

πŸ‘‘ the server side

An OpenSSL server that wishes to support the "use_srtp" extension should also call SSL_CTX_set_tlsext_use_srtp() or SSL_set_tlsext_use_srtp() to indicate the protection profiles that it is willing to negotiate. yes, the server has to opt in too, it's not a mind reader 😭

πŸ”₯ querying what's configured

The currently configured list of protection profiles β€” for either a client or a server β€” can be obtained by calling SSL_get_srtp_profiles(). This returns a stack of SRTP_PROTECTION_PROFILE objects. πŸŽ€

πŸ’€ bestie do NOT free the memory pointed to in the return value of this function. that's not yours. the caller should not free it.

⭐ querying what got negotiated

After a handshake has been completed, the negotiated SRTP protection profile (if any) can be obtained β€” on the client or the server β€” by calling SSL_get_selected_srtp_profile(). This function will return NULL if no SRTP protection profile was negotiated.

πŸ’€ same rule, again: the memory returned from this function should not be freed by the caller.

🧚 getting the actual keying material

If an SRTP protection profile has been successfully negotiated, then the SRTP keying material (on both the client and server) should be obtained via a call to SSL_export_keying_material(3). here's the exact recipe, iykyk:

  • the label value should be "EXTRACTOR-dtls_srtp"
  • the context value should be NULL (use_context is 0)
  • the total length of keying material obtained should be equal to two times the sum of the master key length and the salt length as defined for the protection profile in use

and the order it comes out in, slay:

  1. the client write master key
  2. the server write master key
  3. the client write master salt
  4. the server write master salt

in that order. fr fr. 🌸

🫢 the QUIC caveat

These functions cannot be used with QUIC SSL objects.

  • SSL_CTX_set_tlsext_use_srtp() fails if called on a QUIC SSL context.
  • SSL_set_tlsext_use_srtp() fails if called on a QUIC SSL object.

🌟 RETURN VALUES 🌟

  • SSL_CTX_set_tlsext_use_srtp() and SSL_set_tlsext_use_srtp() return 0 on success or 1 on error. yes bestie, 0 is the good one here β€” read it twice, it's not a typo πŸ™ˆ
  • SSL_get_srtp_profiles() returns a stack of SRTP_PROTECTION_PROFILE objects on success, or NULL on error or if no protection profiles have been configured.
  • SSL_get_selected_srtp_profile() returns a pointer to an SRTP_PROTECTION_PROFILE object if one has been negotiated, or NULL otherwise.

πŸ’œ SEE ALSO πŸ’œ


Copyright 2017-2023 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 ate that πŸ“ this was OpenSSL 3.5.0, dated 2026-09-25 β€” go forth and negotiate your protection profiles responsibly πŸ’–βœ¨

πŸ“¦ where this page comes from