Name

ne_ssl_load_ca, ne_ssl_load_default_ca — load SSL Certificate Authorities

Synopsis

#include <ne_session.h>
int ne_ssl_load_ca(ne_session *session, const char *filename);
int ne_ssl_load_default_ca(ne_session *session);

Description

To indicate that a given CA certificate is trusted by the user, the certificate can be loaded using the ne_ssl_load_ca function. The filename parameter given must specify the location of a PEM-encoded CA certificate.

The SSL library in use by neon may include a default set of CA certificates; calling the ne_ssl_load_default_ca function will indicate that these CAs are trusted by the user.

If no CA certificates are loaded, or the server presents a certificate which is invalid in some way, then the certificate must be manually verified (see ne_ssl_set_verify), otherwise the connection will fail.

Return value

Both ne_ssl_load_ca and ne_ssl_load_default_ca functions return 0 on success, or non-zero on failure.

Examples

Load the CA certificate stored in /path/to/cacert.pem:

ne_session *sess = ne_session_create(...);

if (ne_ssl_load_ca(sess, "/path/to/cacert.pem")) {
   printf("Could not load CA cert: %s\n", ne_get_error(sess));
}

See also

ne_get_error, ne_ssl_set_verify