4.4.5 mysql_ssl_rsa_setup — Create SSL/RSA Files (original) (raw)

4.4.5 mysql_ssl_rsa_setup — Create SSL/RSA Files

This program creates the SSL certificate and key files and RSA key-pair files required to support secure connections using SSL and secure password exchange using RSA over unencrypted connections, if those files are missing.mysql_ssl_rsa_setup can also be used to create new SSL files if the existing ones have expired.

Important

mysql_ssl_rsa_setup helps lower the barrier to using SSL by making it easier to generate the required files. However, certificates generated bymysql_ssl_rsa_setup are self-signed, which is not very secure. After you gain experience using the files created by mysql_ssl_rsa_setup, consider obtaining a CA certificate from a registered certificate authority.

Invoke mysql_ssl_rsa_setup like this:

mysql_ssl_rsa_setup [options]

Typical options are--datadir to specify where to create the files, and--verbose to see theopenssl commands thatmysql_ssl_rsa_setup executes.

mysql_ssl_rsa_setup attempts to create SSL and RSA files using a default set of file names. It works as follows:

  1. mysql_ssl_rsa_setup checks for theopenssl binary at the locations specified by the PATH environment variable. Ifopenssl is not found,mysql_ssl_rsa_setup does nothing. Ifopenssl is present,mysql_ssl_rsa_setup looks for default SSL and RSA files in the MySQL data directory specified by the--datadir option, or the compiled-in data directory if the--datadir option is not given.
  2. mysql_ssl_rsa_setup checks the data directory for SSL files with the following names:
ca.pem  
server-cert.pem  
server-key.pem  
  1. If any of those files are present,mysql_ssl_rsa_setup creates no SSL files. Otherwise, it invokes openssl to create them, plus some additional files:
ca.pem               Self-signed CA certificate  
ca-key.pem           CA private key  
server-cert.pem      Server certificate  
server-key.pem       Server private key  
client-cert.pem      Client certificate  
client-key.pem       Client private key  

These files enable secure client connections using SSL; seeSection 6.3.1, “Configuring MySQL to Use Encrypted Connections”. 4. mysql_ssl_rsa_setup checks the data directory for RSA files with the following names:

private_key.pem      Private member of private/public key pair  
public_key.pem       Public member of private/public key pair  
  1. If any of these files are present,mysql_ssl_rsa_setup creates no RSA files. Otherwise, it invokes openssl to create them. These files enable secure password exchange using RSA over unencrypted connections for accounts authenticated by the sha256_password plugin; seeSection 6.4.1.5, “SHA-256 Pluggable Authentication”.

For information about the characteristics of files created bymysql_ssl_rsa_setup, seeSection 6.3.3.1, “Creating SSL and RSA Certificates and Keys using MySQL”.

At startup, the MySQL server automatically uses the SSL files created by mysql_ssl_rsa_setup to enable SSL if no explicit SSL options are given other than--ssl (possibly along withssl_cipher). If you prefer to designate the files explicitly, invoke clients with the--ssl-ca,--ssl-cert, and--ssl-key options at startup to name the ca.pem,server-cert.pem, andserver-key.pem files, respectively.

The server also automatically uses the RSA files created bymysql_ssl_rsa_setup to enable RSA if no explicit RSA options are given.

If the server is SSL-enabled, clients use SSL by default for the connection. To specify certificate and key files explicitly, use the --ssl-ca,--ssl-cert, and--ssl-key options to name theca.pem,client-cert.pem, andclient-key.pem files, respectively. However, some additional client setup may be required first because mysql_ssl_rsa_setup by default creates those files in the data directory. The permissions for the data directory normally enable access only to the system account that runs the MySQL server, so client programs cannot use files located there. To make the files available, copy them to a directory that is readable (but not writable) by clients:

cp ca.pem client-cert.pem client-key.pem ..  

If the SSL files used for a MySQL installation have expired, you can use mysql_ssl_rsa_setup to create new ones:

  1. Stop the server.
  2. Rename or remove the existing SSL files. You may wish to make a backup of them first. (The RSA files do not expire, so you need not remove them.mysql_ssl_rsa_setup sees that they exist and not overwrite them.)
  3. Run mysql_ssl_rsa_setup with the--datadir option to specify where to create the new files.
  4. Restart the server.

mysql_ssl_rsa_setup supports the following command-line options, which can be specified on the command line or in the [mysql_ssl_rsa_setup],[mysql_install_db], and[mysqld] groups of an option file. For information about option files used by MySQL programs, seeSection 4.2.2.2, “Using Option Files”.

Table 4.11 mysql_ssl_rsa_setup Options

Option Name Description
--datadir Path to data directory
--help Display help message and exit
--suffix Suffix for X.509 certificate Common Name attribute
--uid Name of effective user to use for file permissions
--verbose Verbose mode
--version Display version information and exit