SSL_CTX_GET0_PARAM(3SSL)

πŸ’– SSL_CTX_GET0_PARAM πŸ’–

okay bestie, welcome to the 3SSL corner of the OpenSSL manual 🌸 this one's all about verification parameters β€” the little settings object that decides whether a peer cert is actually, like, allowed to be here. Eight functions, one vibe: poke at the X509_VERIFY_PARAM inside your SSL or SSL_CTX. let's go πŸ¦‹


✨ NAME ✨

SSL_CTX_get0_param, SSL_get0_param, SSL_CTX_set1_param, SSL_set1_param, SSL_CTX_set_purpose, SSL_CTX_set_trust, SSL_set_purpose, SSL_set_trust β€” get and set verification parameters πŸ’…


✨ SYNOPSIS ✨

#include <openssl/ssl.h>

X509_VERIFY_PARAM *SSL_CTX_get0_param(SSL_CTX *ctx);
X509_VERIFY_PARAM *SSL_get0_param(SSL *ssl);
int SSL_CTX_set1_param(SSL_CTX *ctx, X509_VERIFY_PARAM *vpm);
int SSL_set1_param(SSL *ssl, X509_VERIFY_PARAM *vpm);

int SSL_CTX_set_purpose(SSL_CTX *ctx, int purpose);
int SSL_set_purpose(SSL *ssl, int purpose);

int SSL_CTX_set_trust(SSL_CTX *ctx, int trust);
int SSL_set_trust(SSL *ssl, int trust);

✨ DESCRIPTION ✨

so, the getters β€” SSL_CTX_get0_param() and SSL_get0_param() β€” hand you back an internal pointer to the verification parameters for ctx or ssl, respectively πŸ‘‘

🚨 bestie listen β€” the returned pointer must not be freed by the calling application. that's not your pointer to free, it belongs to the context. do not touch. do not free(). i'm so serious 😭

then the setters: SSL_CTX_set1_param() and SSL_set1_param() set the verification parameters to vpm for ctx or ssl.

SSL_CTX_set_purpose() and SSL_set_purpose() are literally just shorthands β€” they set the purpose parameter on the verification parameters object. these are equivalent to calling X509_VERIFY_PARAM_set_purpose() directly. same energy, less typing ✨

and SSL_CTX_set_trust() and SSL_set_trust() are similarly shorthands that set the trust parameter on the verification parameters object. these are equivalent to calling X509_VERIFY_PARAM_set_trust() directly πŸ’…


✨ NOTES ✨

the classic move, fr fr: you grab the params off an SSL_CTX or SSL structure with SSL_CTX_get0_param() or SSL_get0_param(), and then your application modifies them to suit its needs β€” for example, to add a hostname check πŸŽ€


✨ RETURN VALUES ✨

  • SSL_CTX_get0_param() and SSL_get0_param() return a pointer to an X509_VERIFY_PARAM structure πŸ‘‘
  • SSL_CTX_set1_param(), SSL_set1_param(), SSL_CTX_set_purpose(), SSL_set_purpose(), SSL_CTX_set_trust() and SSL_set_trust() return 1 for success and 0 for failure. that's it, that's the whole scoring system πŸ’€

✨ EXAMPLES ✨

check hostname matches "www.foo.com" in peer certificate:

X509_VERIFY_PARAM *vpm = SSL_get0_param(ssl);
X509_VERIFY_PARAM_set1_host(vpm, "www.foo.com", 0);

✨ SEE ALSO ✨

ssl(7), X509_VERIFY_PARAM_set_flags(3) 🫢


✨ HISTORY ✨

these functions were added in OpenSSL 1.0.2. vintage. iconic. still serving πŸ’œ


Copyright 2015-2022 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 it πŸ“ no cap, you now know more about verification params than like 90% of people at any given party 🌈

mwah πŸ’‹ β€” this was OpenSSL 4.0.3, dated 2026-09-29, and the manual page is SSL_CTX_GET0_PARAM(3SSL). periodt. πŸ‘‘

πŸ“¦ where this page comes from