This section describes options that specify whether to use secure connections and the names of certificate and key files. These options can be given on the command line or in an option file. For examples of suggested use and how to check whether a connection is secure, see Section 7.4.4, “Configuring MySQL to Use Secure Connections”.
Table 7.8 Secure-Connection Option Summary
| Format | Description | Introduced |
|---|---|---|
| --skip-ssl | Do not use secure connection | |
| --ssl | Enable secure connection | |
| --ssl-ca | Path of file that contains list of trusted SSL CAs | |
| --ssl-capath | Path of directory that contains trusted SSL CA certificates in PEM format | |
| --ssl-cert | Path of file that contains X509 certificate in PEM format | |
| --ssl-cipher | List of permitted ciphers to use for connection encryption | |
| --ssl-crl | Path of file that contains certificate revocation lists | |
| --ssl-crlpath | Path of directory that contains certificate revocation list files | |
| --ssl-key | Path of file that contains X509 key in PEM format | |
| --ssl-mode | Security state of connection to server | 5.7.11 |
| --ssl-verify-server-cert | Verify server certificate Common Name value against host name used when connecting to server | |
| --tls-version | Protocols permitted for secure connections | 5.7.10 |
This option has different effects on the server and client sides.
NoteThe client-side
--ssloption is deprecated as of MySQL 5.7.11 and is removed in MySQL 8.0. For client programs, it is preferable to use--ssl-modeinstead:Use
--ssl-mode=REQUIREDinstead of--ssl=1or--enable-ssl.Use
--ssl-mode=DISABLEDinstead of--ssl=0,--skip-ssl, or--disable-ssl.No explicit
--ssl-modeoption is equivalent to no explicit--ssloption.
The server-side
--ssloption is not deprecated.For the MySQL server, this option specifies that the server permits but does not require secure connections. The option is enabled on the server side by default as of MySQL 5.7.5, and disabled before 5.7.5. Also as of MySQL 5.7.5, MySQL servers compiled using OpenSSL can generate missing certificate and key files automatically at startup. See Section 7.4.6.1, “Creating SSL and RSA Certificates and Keys using MySQL”.
The server performs certificate and key file autodiscovery as of MySQL 5.7.5 (for servers compiled using OpenSSL) or 5.7.6 (for servers compiled using yaSSL). If
--sslis enabled (possibly along with--ssl-cipher) and other--ssl-options are not given to configure secure connections explicitly, the server attempts to enable support for secure connections automatically at startup:xxxIf the server discovers valid certificate and key files named
ca.pem,server-cert.pem, andserver-key.pemin the data directory, it enables support for secure connections by clients. (The files need not have been autogenerated; what matters is that they have the indicated names and are valid.)If the server does not find valid certificate and key files in the data directory, it continues executing but does not enable secure connections.
For MySQL client programs, the
--ssloption is used as follows:As of MySQL 5.7.7, client programs attempt to establish a secure connection by default whenever the server supports secure connections:
In the absence of an
--ssloption, the client falls back to an unencrypted connection if a secure connection cannot be established.To require a secure connection and fail if one cannot be established, invoke the client with
--sslor a synonym (--ssl=1,--enable-ssl).To use an unencrypted connection, invoke the client with
--ssl=0or a synonym (--skip-ssl,--disable-ssl).
From MySQL 5.7.3 to 5.7.6,
--sslis prescriptive (not advisory as before MySQL 5.7.3): With--ssl, connection attempts fail if a secure connection cannot be established.Before MySQL 5.7.3,
--sslis advisory:--sslpermits but does not require the client to connect to the server using encryption. Therefore, this option is not sufficient in itself to cause a secure connection to be used. For example, if you specify this option for a client program but the server has not been configured to support secure connections, the client falls back to an unencrypted connection.
If other
--ssl-options are given in the absence ofxxx--ssl, the client attempts to connect securely. If the server is configured to support secure connections, the connection attempt fails if a secure connection cannot be established. If the server is not configured for secure connections, the client falls back to an unencrypted connection.As a recommended set of options to enable secure connections, use at least
--ssl-certand--ssl-keyon the server side and--ssl-caon the client side. See Section 7.4.4, “Configuring MySQL to Use Secure Connections”.--sslis implied by other--ssl-options, as indicated in the descriptions for those options.xxxThe
--ssloption in negated form overrides other--ssl-options and indicates that encryption should not be used. To do this, specify the option asxxx--ssl=0or a synonym (--skip-ssl,--disable-ssl). For example, you might have options specified in the[client]group of your option file to use secure connections by default when you invoke MySQL client programs. To use an unencrypted connection instead, invoke the client program with--ssl=0on the command line to override the options in the option file.To require use of secure connections by a MySQL account, use
CREATE USERto create the account with at least aREQUIRE SSLclause, or useALTER USERfor an existing account to add aREQUIREclause. Connections for the account will be rejected unless MySQL supports secure connections and the server and client have been started with the proper secure-connection options.The
REQUIREclause permits other encryption-related options, which can be used to enforce stricter requirements thanREQUIRE SSL. For additional details about which command options may or must be specified by clients that connect using accounts configured using the variousREQUIREoptions, see the description ofREQUIREin Section 14.7.1.2, “CREATE USER Syntax”.The path to a file in PEM format that contains a list of trusted SSL certificate authorities. This option implies
--sslwhen used on the server side, and on the client side before MySQL 5.7.3.If you use encryption when establishing a client connection, to tell the client not to authenticate the server certificate, specify neither
--ssl-canor--ssl-capath. The server still verifies the client according to any applicable requirements established for the client account, and it still uses any--ssl-caor--ssl-capathoption values specified at server startup.The path to a directory that contains trusted SSL certificate authority certificates in PEM format. This option implies
--sslwhen used on the server side, and on the client side before MySQL 5.7.3.If you use encryption when establishing a client connection, to tell the client not to authenticate the server certificate, specify neither
--ssl-canor--ssl-capath. The server still verifies the client according to any applicable requirements established for the client account, and it still uses any--ssl-caor--ssl-capathoption values specified at server startup.MySQL distributions compiled using OpenSSL support the
--ssl-capathoption (see Section 7.4.1, “OpenSSL Versus yaSSL”). Distributions compiled using yaSSL do not because yaSSL does not look in any directory and does not follow a chained certificate tree. yaSSL requires that all components of the CA certificate tree be contained within a single CA certificate tree and that each certificate in the file has a unique SubjectName value. To work around this yaSSL limitation, concatenate the individual certificate files comprising the certificate tree into a new file and specify that file as the value of the--ssl-caoption.The name of the SSL certificate file in PEM format to use for establishing a secure connection. This option implies
--sslwhen used on the server side, and on the client side before MySQL 5.7.3.A list of permissible ciphers to use for connection encryption. If no cipher in the list is supported, encrypted connections will not work. This option implies
--sslwhen used on the server side, and on the client side before MySQL 5.7.3.For greatest portability,
cipher_listshould be a list of one or more cipher names, separated by colons. This format is understood both by OpenSSL and yaSSL. Examples:--ssl-cipher=AES128-SHA --ssl-cipher=DHE-RSA-AES256-SHA:AES128-SHA
OpenSSL supports a more flexible syntax for specifying ciphers, as described in the OpenSSL documentation at http://www.openssl.org/docs/apps/ciphers.html. yaSSL does not, so attempts to use that extended syntax fail for a MySQL distribution compiled using yaSSL.
For information about which encryption ciphers MySQL supports, see Section 7.4.3, “Secure Connection Protocols and Ciphers”.
The path to a file containing certificate revocation lists in PEM format. This option implies
--sslwhen used on the server side, and on the client side before MySQL 5.7.3.If neither
--ssl-crlnor--ssl-crlpathis given, no CRL checks are performed, even if the CA path contains certificate revocation lists.MySQL distributions compiled using OpenSSL support the
--ssl-crloption (see Section 7.4.1, “OpenSSL Versus yaSSL”). Distributions compiled using yaSSL do not because revocation lists do not work with yaSSL.The path to a directory that contains files containing certificate revocation lists in PEM format. This option implies
--sslwhen used on the server side, and on the client side before MySQL 5.7.3.If neither
--ssl-crlnor--ssl-crlpathis given, no CRL checks are performed, even if the CA path contains certificate revocation lists.MySQL distributions compiled using OpenSSL support the
--ssl-crlpathoption (see Section 7.4.1, “OpenSSL Versus yaSSL”). Distributions compiled using yaSSL do not because revocation lists do not work with yaSSL.The name of the SSL key file in PEM format to use for establishing a secure connection. This option implies
--sslwhen used on the server side, and on the client side before MySQL 5.7.3.If the key file is protected by a passphrase, the program prompts the user for the passphrase. The password must be given interactively; it cannot be stored in a file. If the passphrase is incorrect, the program continues as if it could not read the key.
For better security, use a certificate with an RSA key size of of 2048 bits or more.
This option is available only for client programs, not the server. It specifies the security state of the connection to the server. The following option values are permitted:
PREFERRED: Establish a secure (encrypted) connection if the server supports secure connections. Fall back to an unencrypted connection otherwise. This is the default if--ssl-modeis not specified.DISABLED: Establish an unencrypted connection. This is like the legacy--ssl=0option or its synonyms (--skip-ssl,--disable-ssl).REQUIRED: Establish a secure connection if the server supports secure connections. The connection attempt fails if a secure connection cannot be established.VERIFY_CA: LikeREQUIRED, but additionally verify the server TLS certificate against the configured Certificate Authority (CA) certificates. The connection attempt fails if no valid matching CA certificates are found.VERIFY_IDENTITY: LikeVERIFY_CA, but additionally verify that the server certificate matches the host to which the connection is attempted. This is like the legacy--ssl-verify-server-certoption.
Use of the
--ssl-caor--ssl-capathoption implies--ssl-mode=VERIFY_CA, if--ssl-modeis not explicitly set otherwise.If
--ssl-modeis explicit, use of a value other thanVERIFY_CAorVERIFY_IDENTITYwith an explicit--ssl-caor--ssl-capathoption produces a warning that no verification of the server certificate will be done, despite CA certificate options being specified.The
--ssl-modeoption was added in MySQL 5.7.11.To require use of secure connections by a MySQL account, use
CREATE USERto create the account with at least aREQUIRE SSLclause, or useALTER USERfor an existing account to add aREQUIREclause. Connections for the account will be rejected unless MySQL supports secure connections and the server and client have been started with the proper secure-connection options.The
REQUIREclause permits other encryption-related options, which can be used to enforce stricter requirements thanREQUIRE SSL. For additional details about which command options may or must be specified by clients that connect using accounts configured using the variousREQUIREoptions, see the description ofREQUIREin Section 14.7.1.2, “CREATE USER Syntax”.-
Note
This option is deprecated as of MySQL 5.7.11 and is removed in MySQL 8.0. It is preferable to use
--ssl-mode=VERIFY_IDENTITYinstead.This option is available only for client programs, not the server. It causes the client to check the server's Common Name value in the certificate that the server sends to the client. The client verifies that name against the host name the client uses for connecting to the server, and the connection fails if there is a mismatch. For encrypted connections, this option helps prevent man-in-the-middle attacks. Verification is disabled by default.
For client programs, the protocols permitted by the client for encrypted connections. The value is a comma-separated list containing one or more protocol names. The protocols that can be named for this option depend on the SSL library used to compile MySQL. For details, see Section 7.4.3, “Secure Connection Protocols and Ciphers”.
This option was added in MySQL 5.7.10.
On the server side, the
tls_versionsystem variable can be used instead.