| 1 |
# Save the initial number of concurrent sessions |
| 2 |
--source include/count_sessions.inc |
| 3 |
|
| 4 |
--source include/allowed_ciphers.inc |
| 5 |
|
| 6 |
#------------------------------------------------------------------------------ |
| 7 |
|
| 8 |
|
| 9 |
--echo # Global Setup |
| 10 |
call mtr.add_suppression("Failed to initialize TLS for channel: mysql_main"); |
| 11 |
call mtr.add_suppression("Failed to setup SSL"); |
| 12 |
call mtr.add_suppression(".*SSL_CTX_set_default_verify_paths failed"); |
| 13 |
let DATADIR_LOCATION=$MYSQLTEST_VARDIR/mysqld.1/data; |
| 14 |
let server_log= $MYSQLTEST_VARDIR/log/ssl_auto_detect.err; |
| 15 |
let SEARCH_FILE= $server_log; |
| 16 |
|
| 17 |
|
| 18 |
#------------------------------------------------------------------------------ |
| 19 |
|
| 20 |
|
| 21 |
--echo # Case 1 : Enable SSL automatically if ca.pem, server-cert.pem and |
| 22 |
--echo # sever-key.pem are present in data directory |
| 23 |
|
| 24 |
let $restart_file= $MYSQLTEST_VARDIR/tmp/mysqld.1.expect; |
| 25 |
--exec echo "wait" > $restart_file |
| 26 |
--shutdown_server |
| 27 |
--source include/wait_until_disconnected.inc |
| 28 |
|
| 29 |
--echo # Copy SSL certificates before restarting. |
| 30 |
--echo # They should be picked up automatically by server. |
| 31 |
--copy_file std_data/cacert.pem $DATADIR_LOCATION/ca.pem |
| 32 |
--copy_file std_data/server-cert.pem $DATADIR_LOCATION/server-cert.pem |
| 33 |
--copy_file std_data/server-key.pem $DATADIR_LOCATION/server-key.pem |
| 34 |
|
| 35 |
--exec echo "restart:--log-error=$server_log --log-error-verbosity=3" > $restart_file |
| 36 |
--enable_reconnect |
| 37 |
--source include/wait_until_connected_again.inc |
| 38 |
--disable_reconnect |
| 39 |
--echo # Restart completed. |
| 40 |
|
| 41 |
--echo # Search for : Found ca.pem, server-cert.pem and server-key.pem in data directory. Trying to enable SSL support using them. |
| 42 |
let SEARCH_PATTERN= Found ca.pem, server-cert.pem and server-key.pem in data directory. Trying to enable SSL support using them.; |
| 43 |
--source include/search_pattern.inc |
| 44 |
--echo # Search for : CA certificate is self signed.; |
| 45 |
let SEARCH_PATTERN= CA certificate .* is self signed.; |
| 46 |
--source include/search_pattern.inc |
| 47 |
|
| 48 |
--echo # Try to establish SSL connection : This must succeed. |
| 49 |
connect (ssl_root_1,localhost,root,,,,,SSL); |
| 50 |
--replace_regex $ALLOWED_CIPHERS_REGEX |
| 51 |
SHOW STATUS LIKE 'Ssl_cipher'; |
| 52 |
SHOW VARIABLES LIKE 'have_ssl'; |
| 53 |
|
| 54 |
--echo # Check values of ssl_ca, ssl_cert and ssl_key. |
| 55 |
--echo # They should refer to certificate/key files in data directory. |
| 56 |
SHOW VARIABLES LIKE 'ssl_ca'; |
| 57 |
SHOW VARIABLES LIKE 'ssl_cert'; |
| 58 |
SHOW VARIABLES LIKE 'ssl_key'; |
| 59 |
|
| 60 |
connection default; |
| 61 |
disconnect ssl_root_1; |
| 62 |
|
| 63 |
--echo # Connect using mysql client : This must succeed. |
| 64 |
--replace_regex $ALLOWED_CIPHERS_REGEX |
| 65 |
--exec $MYSQL -uroot --ssl-mode=REQUIRED -e "show status like 'Ssl_cipher';" |
| 66 |
|
| 67 |
|
| 68 |
#------------------------------------------------------------------------------ |
| 69 |
|
| 70 |
|
| 71 |
--echo # Case 2 : Remove server-key.pem and observe that server starts |
| 72 |
--echo # without SSL capability |
| 73 |
|
| 74 |
let $restart_file= $MYSQLTEST_VARDIR/tmp/mysqld.1.expect; |
| 75 |
--exec echo "wait" > $restart_file |
| 76 |
--shutdown_server |
| 77 |
--source include/wait_until_disconnected.inc |
| 78 |
|
| 79 |
--remove_file $server_log 25 |
| 80 |
|
| 81 |
--echo # Remove one of the certificates/keys. |
| 82 |
--remove_file $DATADIR_LOCATION/server-key.pem |
| 83 |
|
| 84 |
--exec echo "restart: --log-error=$server_log" > $restart_file |
| 85 |
--enable_reconnect |
| 86 |
--source include/wait_until_connected_again.inc |
| 87 |
--disable_reconnect |
| 88 |
--echo # Restart completed. |
| 89 |
|
| 90 |
--echo # Check value of have_ssl. It must be DISABLED. |
| 91 |
connect (root_2,localhost,root,,,,,); |
| 92 |
SHOW VARIABLES LIKE 'have_ssl'; |
| 93 |
|
| 94 |
connection default; |
| 95 |
disconnect root_2; |
| 96 |
|
| 97 |
--echo # Try creating SSL connection using mysql connection. It should fail. |
| 98 |
--error 1 |
| 99 |
--exec $MYSQL -uroot --ssl-mode=REQUIRED -e "show status like 'Ssl_cipher';" |
| 100 |
|
| 101 |
|
| 102 |
#------------------------------------------------------------------------------ |
| 103 |
|
| 104 |
|
| 105 |
--echo # |
| 106 |
--echo # Bug#21108296 : --SSL-CIPHER OPTION CAUSES SSL INITIALIZATION FAILURE |
| 107 |
--echo # |
| 108 |
|
| 109 |
let $restart_file= $MYSQLTEST_VARDIR/tmp/mysqld.1.expect; |
| 110 |
--exec echo "wait" > $restart_file |
| 111 |
--shutdown_server |
| 112 |
--source include/wait_until_disconnected.inc |
| 113 |
|
| 114 |
--copy_file std_data/server-key.pem $DATADIR_LOCATION/server-key.pem |
| 115 |
|
| 116 |
--exec echo "restart: --log-error=$server_log --ssl-cipher=ECDHE-RSA-AES128-GCM-SHA256 --log-error-verbosity=3 " > $restart_file |
| 117 |
--enable_reconnect |
| 118 |
--source include/wait_until_connected_again.inc |
| 119 |
--disable_reconnect |
| 120 |
--echo # Restart completed. |
| 121 |
|
| 122 |
--echo # Search for : Found ca.pem, server-cert.pem and server-key.pem in data directory. Trying to enable SSL support using them. |
| 123 |
let SEARCH_PATTERN= Found ca.pem, server-cert.pem and server-key.pem in data directory. Trying to enable SSL support using them.; |
| 124 |
--source include/search_pattern.inc |
| 125 |
--echo # Search for : CA certificate is self signed.; |
| 126 |
let SEARCH_PATTERN= CA certificate .* is self signed.; |
| 127 |
--source include/search_pattern.inc |
| 128 |
|
| 129 |
--echo # Try creating SSL connection |
| 130 |
--replace_regex $ALLOWED_CIPHERS_REGEX |
| 131 |
--exec $MYSQL -uroot --ssl-mode=REQUIRED -e "show status like 'Ssl_cipher';" |
| 132 |
|
| 133 |
|
| 134 |
#------------------------------------------------------------------------------ |
| 135 |
|
| 136 |
|
| 137 |
--echo # Global Cleanup |
| 138 |
--remove_file $DATADIR_LOCATION/ca.pem |
| 139 |
--remove_file $DATADIR_LOCATION/server-cert.pem |
| 140 |
--remove_file $DATADIR_LOCATION/server-key.pem |
| 141 |
|
| 142 |
# Wait till all disconnects are completed |
| 143 |
--source include/wait_until_count_sessions.inc |
| 144 |
|
| 145 |
#------------------------------------------------------------------------------ |
| 146 |
|
| 147 |
# Restore default settings in opt file and clean up |
| 148 |
--let $restart_parameters = restart: |
| 149 |
--source include/restart_mysqld.inc |