SSL_LOAD_CLIENT_CA_FILE(3ossl)

πŸ’– SSL_LOAD_CLIENT_CA_FILE(3ossl) β€” load certificate names πŸ’–

okay bestie, sit down, hydrate, because we're about to learn how to slurp certificate names out of files, dirs, and stores. this is a page from the OpenSSL manual (section 3ossl) and honestly? it's giving "quietly essential". let's get into it. πŸŽ€


✨ NAME ✨

SSL_load_client_CA_file_ex, SSL_load_client_CA_file, SSL_add_file_cert_subjects_to_stack, SSL_add_dir_cert_subjects_to_stack, SSL_add_store_cert_subjects_to_stack β€” load certificate names 🌸

like, that's the whole vibe. loading names. of certs. let's go.


πŸ¦‹ SYNOPSIS πŸ¦‹

#include <openssl/ssl.h>

STACK_OF(X509_NAME) *SSL_load_client_CA_file_ex(const char *file,
                                                OSSL_LIB_CTX *libctx,
                                                const char *propq);
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);
int SSL_add_store_cert_subjects_to_stack(STACK_OF(X509_NAME) *stack,
                                         const char *store);

no cap, that's the whole API surface. five functions, one header, infinite possibilities. πŸ’…


🌈 DESCRIPTION 🌈

okay so, real talk β€” these functions are basically the "who's who" collectors for your cert squad.

  • SSL_load_client_CA_file_ex() reads certificates from file and hands you back a STACK_OF(X509_NAME) with all the subject names it found. and the libctx library context plus the propq property query? those get used when it's fetching algorithms from providers. iykyk. ✨
  • SSL_load_client_CA_file() is literally the same energy as SSL_load_client_CA_file_ex(), except it just uses NULL for both the libctx library context and the propq property query. simpler. cozy. iconic. πŸ’œ
  • SSL_add_file_cert_subjects_to_stack() reads certificates from file, and adds their subject name to the stack you already have. not replacing β€” adding. we're building an empire here. πŸ‘‘
  • SSL_add_dir_cert_subjects_to_stack() reads certificates from every single file in the directory dir, and adds their subject name to the already existing stack. every file bestie. all of them. no skipping. πŸ¦‹
  • SSL_add_store_cert_subjects_to_stack() loads certificates from the store URI, and adds their subject name to the already existing stack. store URIs, we love to see it. πŸ“

πŸ“ NOTES πŸ“

okay important lore drop: SSL_load_client_CA_file() reads a file of PEM formatted certificates and extracts the X509_NAMES of the certificates found.

and here's the thing β€” even though the name makes it sound like it's only there to be a support function for SSL_CTX_set_client_CA_list(3), it is not limited to CA certificates. so don't box it in. let it be versatile. main character energy fr fr. πŸ’…


πŸ”₯ RETURN VALUES πŸ”₯

here's what you can get back, bestie. for SSL_load_client_CA_file_ex() and SSL_load_client_CA_file():

  • NULL β€” the operation failed. 😭 go check out the error stack for the reason, because the answer is in there, not in your DMs.
  • Pointer to STACK_OF(X509_NAME) β€” a pointer to the subject names of the successfully read certificates. slay. ✨

and for SSL_add_file_cert_subjects_to_stack(), SSL_add_dir_cert_subjects_to_stack(), and SSL_add_store_cert_subjects_to_stack():

  • 0 (Failure) β€” the operation failed. πŸ’€
  • 1 (Success) β€” the operation succeeded. πŸŽ‰

πŸŽ€ EXAMPLES πŸŽ€

load names of CAs from a file and use it as a client CA list:

 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 */
 ...

see how clean that is? check for NULL, and if you got names, hand them straight over. obsessed. πŸ’–


πŸ‘‘ SEE ALSO πŸ‘‘

ssl(7), ossl_store(7), SSL_CTX_set_client_CA_list(3)

go read those too, bestie. knowledge is a stack and we're pushing to it. 🌸


🧚 HISTORY 🧚

  • SSL_load_client_CA_file_ex() and SSL_add_store_cert_subjects_to_stack() were added in OpenSSL 3.0.

(the others are older than that, they've been here. veterans. respect. 🫢)


Copyright 2000-2024 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>.

no fr, read the license. it's not a vibe suggestion, it's the rules. πŸ™ˆ

and that's the whole page, bestie!! this was OpenSSL 3.5.9, dated 2026-09-29, and you just ate the SSL_LOAD_CLIENT_CA_FILE(3ossl) manpage. periodt. πŸ’…βœ¨πŸŽ€

πŸ“¦ where this page comes from