SSL_CONF_cmd - OpenSSL Documentation (original) (raw)

NAME

SSL_CONF_cmd_value_type, SSL_CONF_cmd - send configuration command

SYNOPSIS

`#include <openssl/ssl.h>

int SSL_CONF_cmd(SSL_CONF_CTX *cctx, const char *cmd, const char *value); int SSL_CONF_cmd_value_type(SSL_CONF_CTX *cctx, const char *cmd); `

DESCRIPTION

The function SSL_CONF_cmd() performs configuration operation cmd with optional parameter value on ctx. Its purpose is to simplify application configuration of SSL_CTX or SSL structures by providing a common framework for command line options or configuration files.

SSL_CONF_cmd_value_type() returns the type of value that cmd refers to.

SUPPORTED COMMAND LINE COMMANDS

Currently supported cmd names for command lines (i.e. when the flag SSL_CONF_CMDLINE is set) are listed below. Note: all cmd names are case sensitive. Unless otherwise stated commands can be used by both clients and servers and the value parameter is not used. The default prefix for command line commands is - and that is reflected below.

SUPPORTED CONFIGURATION FILE COMMANDS

Currently supported cmd names for configuration files (i.e. when the flag SSL_CONF_FLAG_FILE is set) are listed below. All configuration file cmd names are case insensitive so signaturealgorithms is recognised as well as SignatureAlgorithms. Unless otherwise stated the value names are also case insensitive.

Note: the command prefix (if set) alters the recognised cmd values.

SUPPORTED COMMAND TYPES

The function SSL_CONF_cmd_value_type() currently returns one of the following types:

NOTES

The order of operations is significant. This can be used to set either defaults or values which cannot be overridden. For example if an application calls:

SSL_CONF_cmd(ctx, "Protocol", "-SSLv3"); SSL_CONF_cmd(ctx, userparam, uservalue);

it will disable SSLv3 support by default but the user can override it. If however the call sequence is:

SSL_CONF_cmd(ctx, userparam, uservalue); SSL_CONF_cmd(ctx, "Protocol", "-SSLv3");

SSLv3 is always disabled and attempt to override this by the user are ignored.

By checking the return code of SSL_CONF_cmd() it is possible to query if a given cmd is recognised, this is useful if SSL_CONF_cmd() values are mixed with additional application specific operations.

For example an application might call SSL_CONF_cmd() and if it returns -2 (unrecognised command) continue with processing of application specific commands.

Applications can also use SSL_CONF_cmd() to process command lines though the utility function SSL_CONF_cmd_argv() is normally used instead. One way to do this is to set the prefix to an appropriate value using SSL_CONF_CTX_set1_prefix(), pass the current argument to cmd and the following argument to value (which may be NULL).

In this case if the return value is positive then it is used to skip that number of arguments as they have been processed by SSL_CONF_cmd(). If -2 is returned then cmd is not recognised and application specific arguments can be checked instead. If -3 is returned a required argument is missing and an error is indicated. If 0 is returned some other error occurred and this can be reported back to the user.

The function SSL_CONF_cmd_value_type() can be used by applications to check for the existence of a command or to perform additional syntax checking or translation of the command value. For example if the return value is SSL_CONF_TYPE_FILE an application could translate a relative pathname to an absolute pathname.

RETURN VALUES

SSL_CONF_cmd() returns 1 if the value of cmd is recognised and value is NOT used and 2 if both cmd and value are used. In other words it returns the number of arguments processed. This is useful when processing command lines.

A return value of -2 means cmd is not recognised.

A return value of -3 means cmd is recognised and the command requires a value but value is NULL.

A return code of 0 indicates that both cmd and value are valid but an error occurred attempting to perform the operation: for example due to an error in the syntax of value in this case the error queue may provide additional information.

EXAMPLES

Set supported signature algorithms:

SSL_CONF_cmd(ctx, "SignatureAlgorithms", "ECDSA+SHA256:RSA+SHA256:DSA+SHA256");

There are various ways to select the supported protocols.

This set the minimum protocol version to TLSv1, and so disables SSLv3. This is the recommended way to disable protocols.

SSL_CONF_cmd(ctx, "MinProtocol", "TLSv1");

The following also disables SSLv3:

SSL_CONF_cmd(ctx, "Protocol", "-SSLv3");

The following will first enable all protocols, and then disable SSLv3. If no protocol versions were disabled before this has the same effect as "-SSLv3", but if some versions were disables this will re-enable them before disabling SSLv3.

SSL_CONF_cmd(ctx, "Protocol", "ALL,-SSLv3");

Only enable TLSv1.2:

SSL_CONF_cmd(ctx, "MinProtocol", "TLSv1.2"); SSL_CONF_cmd(ctx, "MaxProtocol", "TLSv1.2");

This also only enables TLSv1.2:

SSL_CONF_cmd(ctx, "Protocol", "-ALL,TLSv1.2");

Disable TLS session tickets:

SSL_CONF_cmd(ctx, "Options", "-SessionTicket");

Enable compression:

SSL_CONF_cmd(ctx, "Options", "Compression");

Set supported curves to P-256, P-384:

SSL_CONF_cmd(ctx, "Curves", "P-256:P-384");

SEE ALSO

SSL_CONF_CTX_new(3), SSL_CONF_CTX_set_flags(3), SSL_CONF_CTX_set1_prefix(3), SSL_CONF_CTX_set_ssl_ctx(3), SSL_CONF_cmd_argv(3), SSL_CTX_set_options(3)

HISTORY

The SSL_CONF_cmd() function was added in OpenSSL 1.0.2.

The SSL_OP_NO_SSL2 option doesn't have effect since 1.1.0, but the macro is retained for backwards compatibility.

The SSL_CONF_TYPE_NONE was added in OpenSSL 1.1.0. In earlier versions of OpenSSL passing a command which didn't take an argument would return SSL_CONF_TYPE_UNKNOWN.

MinProtocol and MaxProtocol where added in OpenSSL 1.1.0.

AllowNoDHEKEX and PrioritizeChaCha were added in OpenSSL 1.1.1.

COPYRIGHT

Copyright 2012-2022 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.