NAME
SSL_CTX_load_verify_locations — set default locations for trusted CA certificatesSYNOPSIS
#include <openssl/ssl.h>SSL_CTX_load_verify_locations(SSL_CTX *ctx, const char *CAfile, const char *CApath);
DESCRIPTION
SSL_CTX_load_verify_locations() specifies the locations for ctx, at which CA certificates for verification purposes are located. The certificates available via CAfile and CApath are trusted.NOTES
If CAfile is not NULL, it points to a file of CA certificates in PEM format. The file can contain several CA certificates identified by sequences of:-----BEGIN CERTIFICATE----- ... (CA certificate in base64 encoding) ... -----END CERTIFICATE-----Before, between, and after the certificates arbitrary text is allowed which can be used, e.g., for descriptions of the certificates.
WARNINGS
If several CA certificates matching the name, key identifier, and serial number condition are available, only the first one will be examined. This may lead to unexpected results if the same CA certificate is available with different expiration dates. If a “certificate expired” verification error occurs, no other certificate will be searched. Make sure to not have expired certificates mixed with valid ones.RETURN VALUES
The following return values can occur:- 0
- The operation failed because CAfile and CApath are NULL or the processing at one of the locations specified failed. Check the error stack to find out the reason.
- 1
- The operation succeeded.
EXAMPLES
Generate a CA certificate file with descriptive text from the CA certificates ca1.pem ca2.pem ca3.pem:#!/bin/sh rm CAfile.pem for i in ca1.pem ca2.pem ca3.pem; do openssl x509 -in $i -text >> CAfile.pem done
$ cd /some/where/certs $ rm -f *.[0-9]* *.r[0-9]* $ for c in *.pem; do > [ "$c" = "*.pem" ] && continue > hash=$(openssl x509 -noout -hash -in "$c") > if egrep -q -- '-BEGIN( X509 | TRUSTED | )CERTIFICATE-' "$c"; then > suf=0 > while [ -e $hash.$suf ]; do suf=$(( $suf + 1 )); done > ln -s "$c" $hash.$suf > fi > if egrep -q -- '-BEGIN X509 CRL-' "$c"; then > suf=0 > while [ -e $hash.r$suf ]; do suf=$(( $suf + 1 )); done > ln -s "$c" $hash.r$suf > fi > done