- NAME
- SYNOPSIS
- DESCRIPTION
- NOTES
- RETURN VALUES
- SEE ALSO
- COPYRIGHT

# NAME

SSL_CTX_use_certificate, SSL_CTX_use_certificate_ASN1, SSL_CTX_use_certificate_file, SSL_use_certificate, SSL_use_certificate_ASN1, SSL_use_certificate_file, SSL_CTX_use_certificate_chain_file, SSL_use_certificate_chain_file, SSL_CTX_use_PrivateKey, SSL_CTX_use_PrivateKey_ASN1, SSL_CTX_use_PrivateKey_file, SSL_CTX_use_RSAPrivateKey, SSL_CTX_use_RSAPrivateKey_ASN1, SSL_CTX_use_RSAPrivateKey_file, SSL_use_PrivateKey_file, SSL_use_PrivateKey_ASN1, SSL_use_PrivateKey, SSL_use_RSAPrivateKey, SSL_use_RSAPrivateKey_ASN1, SSL_use_RSAPrivateKey_file, SSL_CTX_check_private_key, SSL_check_private_key - load certificate and key data

# SYNOPSIS

     #include <openssl/ssl.h>

     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_use_certificate_chain_file(SSL *ssl, 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);

# DESCRIPTION

These functions load the certificates and private keys into the SSL_CTX or SSL object, respectively.

The SSL_CTX_* class of functions loads the certificates and keys into the SSL_CTX object ctx. The information is passed to SSL objects ssl created from ctx with SSL_clear(3) is called for this SSL object.

SSL_CTX_use_certificate() loads the certificate x into ctx, SSL_use_certificate() loads x into ssl. The rest of the certificates needed to form the complete certificate chain can be specified using the NOTES

The internal certificate store of OpenSSL can hold several private key/certificate pairs at a time. The certificate used depends on the cipher selected, see also SSL_CTX_add1_chain_cert(3). Note: versions of OpenSSL before 1.0.2 only had a single certificate chain store for all certificate types, OpenSSL 1.0.2 and later have a separate chain store for each type. SSL_CTX_use_certificate_chain_file() should be used instead of the SSL_CTX_use_certificate_file() 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 SSL_CTX_set_default_passwd_cb(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.)

# RETURN VALUES

On success, the functions return 1. Otherwise check out the error stack to find out the reason.

# SEE ALSO

SSL_new(3), SSL_CTX_load_verify_locations(3), SSL_CTX_set_cipher_list(3), SSL_CTX_set_client_cert_cb(3), COPYRIGHT

Copyright 2000-2016 The OpenSSL Project Authors. All Rights Reserved.

Licensed under the OpenSSL license (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.