SSL_CTX_SET0_CA_LIST(3ossl)
π SSL_CTX_SET0_CA_LIST π
okay bestie, welcome to the 3ossl manual page, aka the one where we talk about CA lists β the little stack of CA names that get passed between two peers like β¨ friendship bracelets β¨ for TLS. It's from the OpenSSL fam, and honestly it's giving certificate-request energy the whole way through.
πΈ NAME πΈ
SSL_CTX_set_client_CA_list, SSL_set_client_CA_list, SSL_get_client_CA_list, SSL_CTX_get_client_CA_list, SSL_CTX_add_client_CA, SSL_add_client_CA, SSL_set0_CA_list, SSL_CTX_set0_CA_list, SSL_get0_CA_list, SSL_CTX_get0_CA_list, SSL_add1_to_CA_list, SSL_CTX_add1_to_CA_list, SSL_get0_peer_CA_list β get or set CA list π
β¨ SYNOPSIS β¨
#include <openssl/ssl.h>
void SSL_CTX_set_client_CA_list(SSL_CTX *ctx, STACK_OF(X509_NAME) *list);
void SSL_set_client_CA_list(SSL *s, STACK_OF(X509_NAME) *list);
STACK_OF(X509_NAME) *SSL_get_client_CA_list(const SSL *s);
STACK_OF(X509_NAME) *SSL_CTX_get_client_CA_list(const SSL_CTX *ctx);
int SSL_CTX_add_client_CA(SSL_CTX *ctx, X509 *cacert);
int SSL_add_client_CA(SSL *ssl, X509 *cacert);
void SSL_CTX_set0_CA_list(SSL_CTX *ctx, STACK_OF(X509_NAME) *name_list);
void SSL_set0_CA_list(SSL *s, STACK_OF(X509_NAME) *name_list);
const STACK_OF(X509_NAME) *SSL_CTX_get0_CA_list(const SSL_CTX *ctx);
const STACK_OF(X509_NAME) *SSL_get0_CA_list(const SSL *s);
int SSL_CTX_add1_to_CA_list(SSL_CTX *ctx, const X509 *x);
int SSL_add1_to_CA_list(SSL *ssl, const X509 *x);
const STACK_OF(X509_NAME) *SSL_get0_peer_CA_list(const SSL *s);
π¦ DESCRIPTION π¦
So. The functions down here set and manage the list of CA names that get sent between two communicating peers. That's the whole vibe. π«Ά
For TLS versions 1.2 and earlier, the list of CA names is only sent from the server to the client, and only when the server is requesting a client certificate. So basically: any list of CA names you set is never sent from client to server, and the list retrieved by SSL_get0_peer_CA_list() is always NULL. Always. No cap.
For TLS 1.3, the list of CA names is sent using the certificate_authorities extension, and it may be sent by a client (in the ClientHello message) or by a server (when requesting a certificate). Slay.
In most cases it is not necessary to set CA names on the client side. The list of CA names that are acceptable to the client will be sent in plaintext to the server. This has privacy implications and may also have performance implications if the list is large. π This optional capability was introduced as part of TLSv1.3, and therefore setting CA names on the client side will have no impact if that protocol version has been disabled. Most servers do not need this, so this should be avoided unless required.
fr fr: don't set client-side CA names unless you actually have to. your whole acceptable-CA list goes out in plaintext. that's a vibe check it fails.
The "client CA list" functions below only have an effect when called on the server side.
SSL_CTX_set_client_CA_list()β sets the list of CAs sent to the client when requesting a client certificate for ctx. Ownership of list is transferred to ctx and it should not be freed by the caller.SSL_set_client_CA_list()β sets the list of CAs sent to the client when requesting a client certificate for the chosen ssl, overriding the setting valid for ssl'sSSL_CTXobject. Ownership of list is transferred to s and it should not be freed by the caller.SSL_CTX_get_client_CA_list()β returns the list of client CAs explicitly set for ctx usingSSL_CTX_set_client_CA_list(). The returned list should not be freed by the caller.SSL_get_client_CA_list()β returns the list of client CAs explicitly set for ssl usingSSL_set_client_CA_list()or ssl'sSSL_CTXobject withSSL_CTX_set_client_CA_list(), when in server mode. In client mode,SSL_get_client_CA_listreturns the list of client CAs sent from the server, if any. The returned list should not be freed by the caller.SSL_CTX_add_client_CA()β adds the CA name extracted from cacert to the list of CAs sent to the client when requesting a client certificate for ctx.SSL_add_client_CA()β adds the CA name extracted from cacert to the list of CAs sent to the client when requesting a client certificate for the chosen ssl, overriding the setting valid for ssl'sSSL_CTXobject.
SSL_get0_peer_CA_list() retrieves the list of CA names (if any) the peer has sent. This can be called on either the server or the client side. The returned list should not be freed by the caller. π
The "generic CA list" functions below are very similar to the "client CA list" functions, except that they have an effect on both the server and client sides. The lists of CA names managed are separate β so you cannot (for example) set CA names using the "client CA list" functions and then get them using the "generic CA list" functions. π€ Where a mix of the two types of functions has been used on the server side, then the "client CA list" functions take precedence. Typically, on the server side, the "client CA list " functions should be used in preference. And as noted above, in most cases it is not necessary to set CA names on the client side.
SSL_CTX_set0_CA_list()β sets the list of CAs to be sent to the peer to name_list. Ownership of name_list is transferred to ctx and it should not be freed by the caller.SSL_set0_CA_list()β sets the list of CAs to be sent to the peer to name_list, overriding any list set in the parentSSL_CTXof s. Ownership of name_list is transferred to s and it should not be freed by the caller.SSL_CTX_get0_CA_list()β retrieves any previously set list of CAs set for ctx. The returned list should not be freed by the caller.SSL_get0_CA_list()β retrieves any previously set list of CAs set for s, or if none are set, the list from the parentSSL_CTXis retrieved. The returned list should not be freed by the caller.SSL_CTX_add1_to_CA_list()β appends the CA subject name extracted from x to the list of CAs sent to peer for ctx.SSL_add1_to_CA_list()β appends the CA subject name extracted from x to the list of CAs sent to the peer for s, overriding the setting in the parentSSL_CTX.
π NOTES π
When a TLS/SSL server requests a client certificate (see SSL_CTX_set_verify(3)), it sends a list of CAs, for which it will accept certificates, to the client. Cute, right? It's literally the server saying "here's who I'll accept vibes from." π
This list must explicitly be set using SSL_CTX_set_client_CA_list() or SSL_CTX_set0_CA_list() for ctx, and SSL_set_client_CA_list() or SSL_set0_CA_list() for the specific ssl. The list specified overrides the previous setting. The CAs listed do not become trusted (list only contains the names, not the complete certificates) β use SSL_CTX_load_verify_locations(3) to additionally load them for verification.
If the list of acceptable CAs is compiled in a file, the SSL_load_client_CA_file(3) function can be used to help to import the necessary data. π
SSL_CTX_add_client_CA(), SSL_CTX_add1_to_CA_list(), SSL_add_client_CA() and SSL_add1_to_CA_list() can be used to add additional items to the list of CAs. If no list was specified before using SSL_CTX_set_client_CA_list(), SSL_CTX_set0_CA_list(), SSL_set_client_CA_list() or SSL_set0_CA_list(), a new CA list for ctx or ssl (as appropriate) is opened. β¨
π₯ RETURN VALUES π₯
SSL_CTX_set_client_CA_list(), SSL_set_client_CA_list(), SSL_CTX_set_client_CA_list(), SSL_set_client_CA_list(), SSL_CTX_set0_CA_list() and SSL_set0_CA_list() do not return a value. They just do the thing. Silent. Iconic. π
SSL_CTX_get_client_CA_list(), SSL_get_client_CA_list(), SSL_CTX_get0_CA_list() and SSL_get0_CA_list() return a stack of CA names, or NULL if no CA names are set.
SSL_CTX_add_client_CA(),SSL_add_client_CA(), SSL_CTX_add1_to_CA_list() and SSL_add1_to_CA_list() return 1 for success and 0 for failure.
SSL_get0_peer_CA_list() returns a stack of CA names sent by the peer, or NULL, or an empty stack, if no list was sent.
π EXAMPLES π
Scan all certificates in CAfile and list them as acceptable CAs:
SSL_CTX_set_client_CA_list(ctx, SSL_load_client_CA_file(CAfile));
one line. that's it. that's the whole recipe. ate. π
π SEE ALSO π
ssl(7), SSL_load_client_CA_file(3), SSL_CTX_load_verify_locations(3)
β COPYRIGHT β
Copyright 2000-2018 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>.
and that's the whole page bestie!! π§ this was version 3.5.9, dated 2026-09-29, and it's the SSL_CTX_SET0_CA_LIST(3ossl) page from the OpenSSL manual. go forth and manage your CA lists responsibly, and remember: don't free the list, the caller does not own it ππ mwah, bye!! ππΈπ¦
π¦ where this page comes from
- fedora 43: openssl-devel 1:3.5.9-1.fc43 Β· Apache-2.0
- fedora 43: openssl-devel 1:3.5.9-1.fc43 Β· Apache-2.0
- fedora 44: openssl-devel 1:3.5.9-1.fc44 Β· Apache-2.0
- fedora 44: openssl-devel 1:3.5.9-1.fc44 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms