SSL_LOAD_CLIENT_CA_FILE(3)
πΈ NAME πΈ
okay so bestie, this is the SSL_LOAD_CLIENT_CA_FILE(3) page from the Library Functions Manual, and it's all about loading certificate names from files. the main characters are SSL_load_client_CA_file, SSL_add_file_cert_subjects_to_stack, and SSL_add_dir_cert_subjects_to_stack β and yes, they ate. π
β¨ SYNOPSIS β¨
the whole libssl / libcrypto include situation is literally this, no cap:
library βlibsslβ libcrypto #include <openssl/ssl.h>
STACK_OF(X509_NAME) *
SSL_load_client_CA_file(const char *file);
int
SSL_add_file_cert_subjects_to_stack(STACK_OF(X509_NAME) *stack,
const char *file);
int
SSL_add_dir_cert_subjects_to_stack(STACK_OF(X509_NAME) *stack,
const char *dir);
π¦ DESCRIPTION π¦
SSL_load_client_CA_file() is the main character here: it reads PEM formatted certificates from file and returns a new STACK_OF(X509_NAME) with the subject names found. and yeah, the name is giving βsupport function for SSL_CTX_set_client_CA_list(3)β energy, but it is not limited to CA certificates. periodt.
SSL_add_file_cert_subjects_to_stack() is similar, except the names are added to the existing stack.
SSL_add_dir_cert_subjects_to_stack() has directory-gremlin energy: it calls SSL_add_file_cert_subjects_to_stack() on every file in the directory dir.
if a name is already on the stack, all these functions skip it and do not add it again β no duplicates, no stress. π
π RETURN VALUES π
SSL_load_client_CA_file()returns a pointer to the newSTACK_OF(X509_NAME)orNULLon failure.SSL_add_file_cert_subjects_to_stack()andSSL_add_dir_cert_subjects_to_stack()return1for success or0for failure.- all these functions treat empty files and directories as failures. yes bestie, empty = fail.
- in some cases of failure, the reason can be determined with
ERR_get_error(3).
π EXAMPLES π
load names of CAs from a file and use it as a client CA list β the manual literally shows this:
SSL_CTX *ctx;
STACK_OF(X509_NAME) *cert_names;
...
cert_names = SSL_load_client_CA_file("/path/to/CAfile.pem");
if (cert_names != NULL)
SSL_CTX_set_client_CA_list(ctx, cert_names);
else
error_handling();
...
π₯ SEE ALSO π₯
go read these too, iykyk:
π§ HISTORY π§
history lesson, but make it cute:
SSL_load_client_CA_file()first appeared in SSLeay 0.8.0 and has been available since OpenBSD 2.4.SSL_add_file_cert_subjects_to_stack()andSSL_add_dir_cert_subjects_to_stack()first appeared in OpenSSL 0.9.2b and have been available since OpenBSD 2.6.
π AUTHORS π
SSL_add_file_cert_subjects_to_stack() and SSL_add_dir_cert_subjects_to_stack() were written by Ben Laurie (<ben@openssl.org>) in 1999. iconic behavior, honestly. π
π BUGS π
okay bestie, read this part before you ship, fr fr:
- in some cases of failure, for example for empty files and directories, these functions fail to report an error, in the sense that
ERR_get_error(3)does not work. - even in case of failure, for example when parsing one of the files or certificates fails,
SSL_add_file_cert_subjects_to_stack()andSSL_add_dir_cert_subjects_to_stack()may still have added some certificates to the stack. - the behaviour of
SSL_add_dir_cert_subjects_to_stack()is non-deterministic. if parsing one file fails, parsing of the whole directory is aborted. files in the directory are not parsed in any specific order. for example, adding an empty file to dir may or may not cause some of the other files to be ignored.
this page came from Debian and is dated June 8, 2025; the manual is SSL_LOAD_CLIENT_CA_FILE(3). bye bestie, go be iconic with those cert names π
β¨
π¦ where this page comes from
- alpine 3.24: libressl-doc 4.3.1-r0 Β· custom
- arch rolling: libressl 4.4.0-1 Β· ISC AND custom:OpenSSL
- Copyright (c) 2016 Ingo Schwarze <schwarze@openbsd.org>
- Copyright (c) 2000 The OpenSSL Project. All rights reserved
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms