#include
int SSL_CTX_use_certificate(SSL_CTX *ctx, X509 *x); int SSL_CTX_use_certificate_ASN1(SSL_CTX *ctx, int len, unsigned char *d); int SSL_CTX_use_certificate_file(SSL_CTX *ctx, const char *file, int type); int SSL_use_certificate(SSL *ssl, X509 *x); int SSL_use_certificate_ASN1(SSL *ssl, unsigned char *d, int len); int SSL_use_certificate_file(SSL *ssl, const char *file, int type);
int SSL_CTX_use_certificate_chain_file(SSL_CTX *ctx, const char *file);
int SSL_CTX_use_PrivateKey(SSL_CTX *ctx, EVP_PKEY *pkey); int SSL_CTX_use_PrivateKey_ASN1(int pk, SSL_CTX *ctx, unsigned char *d, long len); int SSL_CTX_use_PrivateKey_file(SSL_CTX *ctx, const char *file, int type); int SSL_CTX_use_RSAPrivateKey(SSL_CTX *ctx, RSA *rsa); int SSL_CTX_use_RSAPrivateKey_ASN1(SSL_CTX *ctx, unsigned char *d, long len); int SSL_CTX_use_RSAPrivateKey_file(SSL_CTX *ctx, const char *file, int type); int SSL_use_PrivateKey(SSL *ssl, EVP_PKEY *pkey); int SSL_use_PrivateKey_ASN1(int pk,SSL *ssl, unsigned char *d, long len); int SSL_use_PrivateKey_file(SSL *ssl, const char *file, int type); int SSL_use_RSAPrivateKey(SSL *ssl, RSA *rsa); int SSL_use_RSAPrivateKey_ASN1(SSL *ssl, unsigned char *d, long len); int SSL_use_RSAPrivateKey_file(SSL *ssl, const char *file, int type);
int SSL_CTX_check_private_key(const SSL_CTX *ctx); int SSL_check_private_key(const SSL *ssl);
The SSL_CTX_* class of functions loads the certificates and keys into the SSL_CTX object ccttxx. The information is passed to SSL objects ssssll created from ccttxx with _S_S_L___n_e_w(3) by copying, so that changes applied to ccttxx do not propagate to already existing SSL objects.
The SSL_* class of functions only loads certificates and keys into a specific SSL object. The specific information is kept, when _S_S_L___c_l_e_a_r(3) is called for this SSL object.
_S_S_L___C_T_X___u_s_e___c_e_r_t_i_f_i_c_a_t_e_(_) loads the certificate xx into ccttxx, _S_S_L___u_s_e___c_e_r_t_i_f_i_c_a_t_e_(_) loads xx into ssssll. The rest of the certificates needed to form the complete certificate chain can be specified using the _S_S_L___C_T_X___a_d_d___e_x_t_r_a___c_h_a_i_n___c_e_r_t(3) function.
_S_S_L___C_T_X___u_s_e___c_e_r_t_i_f_i_c_a_t_e___A_S_N_1_(_) loads the ASN1 encoded certificate from the memory location dd (with length lleenn) into ccttxx, _S_S_L___u_s_e___c_e_r_t_i_f_i_c_a_t_e___A_S_N_1_(_) loads the ASN1 encoded certificate into ssssll.
_S_S_L___C_T_X___u_s_e___c_e_r_t_i_f_i_c_a_t_e___f_i_l_e_(_) loads the first certificate stored in ffiillee into ccttxx. The formatting ttyyppee of the certificate must be specified from the known types SSL_FILETYPE_PEM, SSL_FILETYPE_ASN1. _S_S_L___u_s_e___c_e_r_t_i_f_i_c_a_t_e___f_i_l_e_(_) loads the certificate from ffiillee into ssssll. See the NOTES section on why _S_S_L___C_T_X___u_s_e___c_e_r_t_i_f_i_c_a_t_e___c_h_a_i_n___f_i_l_e_(_) should be preferred.
_S_S_L___C_T_X___u_s_e___c_e_r_t_i_f_i_c_a_t_e___c_h_a_i_n___f_i_l_e_(_) loads a certificate chain from ffiillee into ccttxx. The certificates must be in PEM format and must be sorted starting with the subject's certificate (actual client or server certificate), followed by intermediate CA certificates if applicable, and ending at the highest level (root) CA. There is no corresponding function working on a single SSL object.
_S_S_L___C_T_X___u_s_e___P_r_i_v_a_t_e_K_e_y_(_) adds ppkkeeyy as private key to ccttxx. _S_S_L___C_T_X___u_s_e___R_S_A_P_r_i_v_a_t_e_K_e_y_(_) adds the private key rrssaa of type RSA to ccttxx. _S_S_L___u_s_e___P_r_i_v_a_t_e_K_e_y_(_) adds ppkkeeyy as private key to ssssll; _S_S_L___u_s_e___R_S_A_P_r_i_v_a_t_e_K_e_y_(_) adds rrssaa as private key of type RSA to ssssll. If a certificate has already been set and the private does not belong to the certificate an error is returned. To change a certificate, private key pair the new certificate needs to be set with _S_S_L___u_s_e___c_e_r_t_i_f_i_c_a_t_e_(_) or _S_S_L___C_T_X___u_s_e___c_e_r_t_i_f_i_c_a_t_e_(_) before setting the private key with _S_S_L___C_T_X___u_s_e___P_r_i_v_a_t_e_K_e_y_(_) or _S_S_L___u_s_e___P_r_i_v_a_t_e_K_e_y_(_).
_S_S_L___C_T_X___u_s_e___P_r_i_v_a_t_e_K_e_y___A_S_N_1_(_) adds the private key of type ppkk stored at memory location dd (length lleenn) to ccttxx. _S_S_L___C_T_X___u_s_e___R_S_A_P_r_i_v_a_t_e_K_e_y___A_S_N_1_(_) adds the private key of type RSA stored at memory location dd (length lleenn) to ccttxx. _S_S_L___u_s_e___P_r_i_v_a_t_e_K_e_y___A_S_N_1_(_) and _S_S_L___u_s_e___R_S_A_P_r_i_v_a_t_e_K_e_y___A_S_N_1_(_) add the private key to ssssll.
_S_S_L___C_T_X___u_s_e___P_r_i_v_a_t_e_K_e_y___f_i_l_e_(_) adds the first private key found in ffiillee to ccttxx. The formatting ttyyppee of the certificate must be specified from the known types SSL_FILETYPE_PEM, SSL_FILETYPE_ASN1. _S_S_L___C_T_X___u_s_e___R_S_A_P_r_i_v_a_t_e_K_e_y___f_i_l_e_(_) adds the first private RSA key found in ffiillee to ccttxx. _S_S_L___u_s_e___P_r_i_v_a_t_e_K_e_y___f_i_l_e_(_) adds the first private key found in ffiillee to ssssll; _S_S_L___u_s_e___R_S_A_P_r_i_v_a_t_e_K_e_y___f_i_l_e_(_) adds the first private RSA key found to ssssll.
_S_S_L___C_T_X___c_h_e_c_k___p_r_i_v_a_t_e___k_e_y_(_) checks the consistency of a private key with the corresponding certificate loaded into ccttxx. If more than one key/certificate pair (RSA/DSA) is installed, the last item installed will be checked. If e.g. the last item was a RSA certificate or key, the RSA key/certificate pair will be checked. _S_S_L___c_h_e_c_k___p_r_i_v_a_t_e___k_e_y_(_) performs the same check for ssssll. If no key/certificate was explicitly added for this ssssll, the last item added into ccttxx will be checked.
When reading certificates and private keys from file, files of type SSL_FILETYPE_ASN1 (also known as DDEERR, binary encoding) can only contain one certificate or private key, consequently _S_S_L___C_T_X___u_s_e___c_e_r_t_i_f_i_c_a_t_e___c_h_a_i_n___f_i_l_e_(_) is only applicable to PEM formatting. Files of type SSL_FILETYPE_PEM can contain more than one item.
_S_S_L___C_T_X___u_s_e___c_e_r_t_i_f_i_c_a_t_e___c_h_a_i_n___f_i_l_e_(_) adds the first certificate found in the file to the certificate store. The other certificates are added to the store of chain certificates using _S_S_L___C_T_X___a_d_d___e_x_t_r_a___c_h_a_i_n___c_e_r_t(3). There exists only one extra chain store, so that the same chain is appended to both types of certificates, RSA and DSA! If it is not intended to use both type of certificate at the same time, it is recommended to use the _S_S_L___C_T_X___u_s_e___c_e_r_t_i_f_i_c_a_t_e___c_h_a_i_n___f_i_l_e_(_) instead of the _S_S_L___C_T_X___u_s_e___c_e_r_t_i_f_i_c_a_t_e___f_i_l_e_(_) function in order to allow the use of complete certificate chains even when no trusted CA storage is used or when the CA issuing the certificate shall not be added to the trusted CA storage.
If additional certificates are needed to complete the chain during the TLS negotiation, CA certificates are additionally looked up in the locations of trusted CA certificates, see _S_S_L___C_T_X___l_o_a_d___v_e_r_i_f_y___l_o_c_a_t_i_o_n_s(3).
The private keys loaded from file can be encrypted. In order to successfully load encrypted keys, a function returning the passphrase must have been supplied, see _S_S_L___C_T_X___s_e_t___d_e_f_a_u_l_t___p_a_s_s_w_d___c_b(3). (Certificate files might be encrypted as well from the technical point of view, it however does not make sense as the data in the certificate is considered public anyway.)