polardbxengine/mysql-test/suite/auth_sec/t/ssl_auto_detect.test

145 lines
5.0 KiB
Plaintext

# Save the initial number of concurrent sessions
--source include/count_sessions.inc
--source include/allowed_ciphers.inc
#------------------------------------------------------------------------------
--echo # Global Setup
call mtr.add_suppression("Failed to setup SSL");
call mtr.add_suppression(".*SSL_CTX_set_default_verify_paths failed");
let DATADIR_LOCATION=$MYSQLTEST_VARDIR/mysqld.1/data;
let server_log= $MYSQLTEST_VARDIR/log/ssl_auto_detect.err;
let SEARCH_FILE= $server_log;
#------------------------------------------------------------------------------
--echo # Case 1 : Enable SSL automatically if ca.pem, server-cert.pem and
--echo # sever-key.pem are present in data directory
let $restart_file= $MYSQLTEST_VARDIR/tmp/mysqld.1.expect;
--exec echo "wait" > $restart_file
--shutdown_server
--source include/wait_until_disconnected.inc
--echo # Copy SSL certificates before restarting.
--echo # They should be picked up automatically by server.
--copy_file std_data/cacert.pem $DATADIR_LOCATION/ca.pem
--copy_file std_data/server-cert.pem $DATADIR_LOCATION/server-cert.pem
--copy_file std_data/server-key.pem $DATADIR_LOCATION/server-key.pem
--exec echo "restart:--log-error=$server_log --log-error-verbosity=3" > $restart_file
--enable_reconnect
--source include/wait_until_connected_again.inc
--disable_reconnect
--echo # Restart completed.
--echo # Search for : Found ca.pem, server-cert.pem and server-key.pem in data directory. Trying to enable SSL support using them.
let SEARCH_PATTERN= Found ca.pem, server-cert.pem and server-key.pem in data directory. Trying to enable SSL support using them.;
--source include/search_pattern.inc
--echo # Search for : CA certificate is self signed.;
let SEARCH_PATTERN= CA certificate .* is self signed.;
--source include/search_pattern.inc
--echo # Try to establish SSL connection : This must succeed.
connect (ssl_root_1,localhost,root,,,,,SSL);
--replace_regex $ALLOWED_CIPHERS_REGEX
SHOW STATUS LIKE 'Ssl_cipher';
SHOW VARIABLES LIKE 'have_ssl';
--echo # Check values of ssl_ca, ssl_cert and ssl_key.
--echo # They should refer to certificate/key files in data directory.
SHOW VARIABLES LIKE 'ssl_ca';
SHOW VARIABLES LIKE 'ssl_cert';
SHOW VARIABLES LIKE 'ssl_key';
connection default;
disconnect ssl_root_1;
--echo # Connect using mysql client : This must succeed.
--replace_regex $ALLOWED_CIPHERS_REGEX
--exec $MYSQL -uroot --ssl-mode=REQUIRED -e "show status like 'Ssl_cipher';"
#------------------------------------------------------------------------------
--echo # Case 2 : Remove server-key.pem and observe that server starts
--echo # without SSL capability
let $restart_file= $MYSQLTEST_VARDIR/tmp/mysqld.1.expect;
--exec echo "wait" > $restart_file
--shutdown_server
--source include/wait_until_disconnected.inc
--remove_file $server_log 25
--echo # Remove one of the certificates/keys.
--remove_file $DATADIR_LOCATION/server-key.pem
--exec echo "restart: --log-error=$server_log" > $restart_file
--enable_reconnect
--source include/wait_until_connected_again.inc
--disable_reconnect
--echo # Restart completed.
--echo # Check value of have_ssl. It must be DISABLED.
connect (root_2,localhost,root,,,,,);
SHOW VARIABLES LIKE 'have_ssl';
connection default;
disconnect root_2;
--echo # Try creating SSL connection using mysql connection. It should fail.
--error 1
--exec $MYSQL -uroot --ssl-mode=REQUIRED -e "show status like 'Ssl_cipher';"
#------------------------------------------------------------------------------
--echo #
--echo # Bug#21108296 : --SSL-CIPHER OPTION CAUSES SSL INITIALIZATION FAILURE
--echo #
let $restart_file= $MYSQLTEST_VARDIR/tmp/mysqld.1.expect;
--exec echo "wait" > $restart_file
--shutdown_server
--source include/wait_until_disconnected.inc
--copy_file std_data/server-key.pem $DATADIR_LOCATION/server-key.pem
--exec echo "restart: --log-error=$server_log --ssl-cipher=DHE-RSA-AES256-SHA --log-error-verbosity=3 " > $restart_file
--enable_reconnect
--source include/wait_until_connected_again.inc
--disable_reconnect
--echo # Restart completed.
--echo # Search for : Found ca.pem, server-cert.pem and server-key.pem in data directory. Trying to enable SSL support using them.
let SEARCH_PATTERN= Found ca.pem, server-cert.pem and server-key.pem in data directory. Trying to enable SSL support using them.;
--source include/search_pattern.inc
--echo # Search for : CA certificate is self signed.;
let SEARCH_PATTERN= CA certificate .* is self signed.;
--source include/search_pattern.inc
--echo # Try creating SSL connection
--replace_regex $ALLOWED_CIPHERS_REGEX
--exec $MYSQL -uroot --ssl-mode=REQUIRED -e "show status like 'Ssl_cipher';"
#------------------------------------------------------------------------------
--echo # Global Cleanup
--remove_file $DATADIR_LOCATION/ca.pem
--remove_file $DATADIR_LOCATION/server-cert.pem
--remove_file $DATADIR_LOCATION/server-key.pem
# Wait till all disconnects are completed
--source include/wait_until_count_sessions.inc
#------------------------------------------------------------------------------