SSL_CTX_SET_CIPHER_LIST(3)

NAME
SSL_CTX_set_cipher_list, SSL_set_cipher_list - choose list of available SSL_CIPHERs

SYNOPSIS
#include <openssl/ssl.h>
int
SSL_CTX_set_cipher_list(SSL_CTX *ctx, const char *control);
int
SSL_set_cipher_list(SSL *ssl, const char *control);

DESCRIPTION
SSL_CTX_set_cipher_list() sets the list of available cipher suites for ctx using the control string. The list of cipher suites is inherited by all ssl objects created from ctx.

SSL_set_cipher_list() sets the list of cipher suites only for ssl.

The control string consists of one or more control words separated by colon characters (‘’):. Space (‘ ’), semicolon (‘’);, and comma (‘’), characters can also be used as separators. Each control words selects a set of cipher suites and can take one of the following optional prefix characters:

prefix:
    Those of the selected cipher suites that have not been made available yet are added to the end of the list of available cipher suites, preserving their order.

Prefixed minus sign (‘-’):
    Those of the selected cipher suites that have been made available earlier are moved back from the list of available cipher suites to the beginning of the list of unavailable cipher suites, also preserving their order.

Prefixed plus sign (‘+’):
    Those of the selected cipher suites have been made available earlier are moved to end of the list of available cipher suites, reducing their priority, but preserving the order among themselves.

Prefixed exclamation mark (‘’)!:
    The selected cipher suites are permanently deleted, no matter whether they had earlier been made available or not, and can no longer be added or re-added by later words.

The following special words can only be used without a prefix:

DEFAULT
    An alias for ALL:!aNULL:!eNULL. It can only be used as the first word. The DEFAULT cipher list can be displayed with the openssl(1) ciphers command.

@SECLEVEL=n
    Set the security level to n, which should be a number between zero and five. See SSL_CTX_set_security_level(3) for details.

@STRENGTH
    Sort the list by decreasing encryption strength, preserving the order of cipher suites that have the same strength. It is usually given as the last word.

The following words can be used to select groups of cipher suites, with or without a prefix character. If two or more of these words are joined with plus signs (‘+’) to form a longer word, only the intersection of the specified sets is selected.

ADH Cipher suites using ephemeral DH for key exchange without doing any server authentication. Equivalent to DH+aNULL.

AEAD
    Cipher suites using Authenticated Encryption with Additional Data.

AECDH
    Cipher suites using ephemeral ECDH for key exchange without doing any server authentication. Equivalent to ECDH+aNULL.

aECDSA
    Cipher suites using ECDSA server authentication.

AES Cipher suites using AES or AESGCM for symmetric encryption.

AES128
    Cipher suites using AES(128) or AESGCM(128) for symmetric encryption.

AES256
    Cipher suites using AES(256) or AESGCM(256) for symmetric encryption.

AESGCM
    Cipher suites using AESGCM for symmetric encryption.

aGOST
    An alias for aGOST01.

aGOST01
    Cipher suites using GOST R 34.10-2001 server authentication.

ALL All cipher suites except those selected by eNULL.

aNULL
    Cipher suites that don't do any server authentication. Not enabled by DEFAULT. Beware of man-in-the-middle attacks.

aRSA
    Cipher suites using RSA server authentication.

CAMELLIA
    Cipher suites using Camellia for symmetric encryption.

CAMELLIA128
    Cipher suites using Camellia(128) for symmetric encryption.

CAMELLIA256
    Cipher suites using Camellia(256) for symmetric encryption.

CHACHA20
    Cipher suites using ChaCha20-Poly1305 for symmetric encryption.

COMPLEMENTOFALL
    Cipher suites that are not included in ALL. Currently an alias for eNULL.

COMPLEMENTOFDEFAULT
    Cipher suites that are included in ALL, but not included in DEFAULT. Currently similar to aNULL:!eNULL except for the order of the cipher suites which are not selected.

3DES
    Cipher suites using triple DES for symmetric encryption.

DH  Cipher suites using ephemeral DH for key exchange.

DHE Cipher suites using ephemeral DH for key exchange, but excluding those that don't do any server authentication. Similar to DH:!aNULL except for the order of the cipher suites which are not selected.

ECDH
    Cipher suites using ephemeral ECDH for key exchange.

ECDHE
    Cipher suites using ephemeral ECDH for key exchange, but excluding those that don't do any server authentication. Similar to ECDH:!aNULL except for the order of the cipher suites which are not selected.

ECDSA
    An alias for aECDSA.

eNULL
    Cipher suites that do not use any encryption. Not enabled by DEFAULT, and not even included in ALL.

GOST89MAC
    Cipher suites using GOST 28147-89 for message authentication instead of HMAC.

GOST94
    Cipher suites using HMAC based on GOST R 34.11-94 for message authentication.

HIGH
    Cipher suites of high strength.

kGOST
    Cipher suites using VKO 34.10 key exchange, specified in RFC 4357.

kRSA
    Cipher suites using RSA key exchange.

LOW Cipher suites of low strength.

MD5 Cipher suites using MD5 for message authentication.

MEDIUM
    Cipher suites of medium strength.

NULL
    An alias for eNULL.

RC4 Cipher suites using RC4 for symmetric encryption.

RSA Cipher suites using RSA for both key exchange and server authentication. Equivalent to kRSA+aRSA.

SHA An alias for SHA1.

SHA1
    Cipher suites using SHA1 for message authentication.

SHA256
    Cipher suites using SHA256 for message authentication.

SHA384
    Cipher suites using SHA384 for message authentication.

SSLv3
    An alias for TLSv1.

STREEBOG256
    Cipher suites using STREEBOG256 for message authentication.

TLSv1
    Cipher suites usable with the TLSv1.0, TLSv1.1, and TLSv1.2 protocols.

TLSv1.2
    Cipher suites for the TLSv1.2 protocol.

TLSv1.3
    Cipher suites for the TLSv1.3 protocol. If the control string selects at least one cipher suite but neither contains the word TLSv1.3 nor specifically includes nor excludes any TLSv1.3 cipher suites, all the TLSv1.3 cipher suites are made available, too.

The full words returned by the openssl(1) ciphers command can be used to select individual cipher suites.

The following are deprecated aliases:

avoid: | use:
EDH | DHE
EECDH | ECDHE
kEDH | DH
kEECDH | ECDH

Unknown words are silently ignored, selecting no cipher suites. Failure is only flagged if the control string contains invalid bytes or if no matching cipher suites are available at all.

On the client side, including a cipher suite into the list of available cipher suites is sufficient for using it. On the server side, all cipher suites have additional requirements. ADH ciphers don't need a certificate, but DH-parameters must have been set. All other cipher suites need a corresponding certificate and key.

A RSA cipher can only be chosen when an RSA certificate is available. RSA ciphers using DHE need a certificate and key and additional DH-parameters (see SSL_CTX_set_tmp_dh_callback(3)).

When these conditions are not met for any cipher suite in the list (for example, a client only supports export RSA ciphers with an asymmetric key length of 512 bits and the server is not configured to use temporary RSA keys), the “no shared cipher” (SSL_R_NO_SHARED_CIPHER) error is generated and the handshake will fail.

RETURN VALUES
SSL_CTX_set_cipher_list() and SSL_set_cipher_list() return 1 if any cipher suite could be selected and 0 on complete failure.

SEE ALSO
ssl(3), SSL_CTX_set1_groups(3), SSL_CTX_set_tmp_dh_callback(3), SSL_CTX_use_certificate(3), SSL_get_ciphers(3)

HISTORY
SSL_CTX_set_cipher_list() and SSL_set_cipher_list() first appeared in SSLeay 0.5.2 and have been available since OpenBSD 2.4.

CAVEATS
In LibreSSL, SSL_CTX_set_cipher_list() and SSL_set_cipher_list() can be used to configure the list of available cipher suites for all versions of the TLS protocol, whereas in OpenSSL, they only control cipher suites for protocols up to TLSv1.2. If compatibility with OpenSSL is required, the list of available TLSv1.3 cipher suites can only be changed with SSL_set_ciphersuites().