|
| 1 | +--source include/have_ndb.inc |
| 2 | +--source suite/ndb_tls/include/check_openssl.inc |
| 3 | + |
| 4 | +## TEMPORARILY SKIP THIS TEST ON WINDOWS |
| 5 | +## |
| 6 | +## Remote Key Signing (at line 106) will time out very slowly and create |
| 7 | +## crash dumps. Use the testNdbProcess-t unit test to isolate this issue, |
| 8 | +## then re-enable this test on Windows. |
| 9 | +## |
| 10 | +--source include/not_windows.inc |
| 11 | + |
| 12 | +# The MySQL server is up |
| 13 | +SELECT 1; |
| 14 | + |
| 15 | +# On startup, none of the files exist |
| 16 | +--error 1 |
| 17 | +--file_exists $MYSQLTEST_VARDIR/mysql_cluster.1/NDB-Cluster-cert |
| 18 | +--error 1 |
| 19 | +--file_exists $MYSQLTEST_VARDIR/mysql_cluster.1/NDB-Cluster-private-key |
| 20 | +--error 1 |
| 21 | +--file_exists $MYSQLTEST_VARDIR/mysql_cluster.1/ndb-api-private-key |
| 22 | + |
| 23 | +# Create a CA |
| 24 | +--exec $NDB_SIGN_KEYS --create-CA |
| 25 | + |
| 26 | +# Now the CA files exist |
| 27 | +--file_exists $MYSQLTEST_VARDIR/mysql_cluster.1/NDB-Cluster-cert |
| 28 | +--file_exists $MYSQLTEST_VARDIR/mysql_cluster.1/NDB-Cluster-private-key |
| 29 | + |
| 30 | +# Create all the keys and certs for this cluster |
| 31 | +--exec $NDB_SIGN_KEYS --create-key |
| 32 | +--file_exists $MYSQLTEST_VARDIR/mysql_cluster.1/NDB-Cluster-cert |
| 33 | +--list_files $MYSQLTEST_VARDIR/mysql_cluster.1 ndb-* |
| 34 | + |
| 35 | +# Remove them; remove_file will fail if a file does not exist. |
| 36 | +# On Windows, private key files must be writable to be removed. |
| 37 | +--chmod 0600 $MYSQLTEST_VARDIR/mysql_cluster.1/ndb-api-private-key |
| 38 | +--chmod 0600 $MYSQLTEST_VARDIR/mysql_cluster.1/ndb-data-node-private-key |
| 39 | +--chmod 0600 $MYSQLTEST_VARDIR/mysql_cluster.1/ndb-mgm-server-private-key |
| 40 | + |
| 41 | +--remove_file $MYSQLTEST_VARDIR/mysql_cluster.1/ndb-api-private-key |
| 42 | +--remove_file $MYSQLTEST_VARDIR/mysql_cluster.1/ndb-api-cert |
| 43 | +--remove_file $MYSQLTEST_VARDIR/mysql_cluster.1/ndb-data-node-private-key |
| 44 | +--remove_file $MYSQLTEST_VARDIR/mysql_cluster.1/ndb-data-node-cert |
| 45 | +--remove_file $MYSQLTEST_VARDIR/mysql_cluster.1/ndb-mgm-server-private-key |
| 46 | +--remove_file $MYSQLTEST_VARDIR/mysql_cluster.1/ndb-mgm-server-cert |
| 47 | + |
| 48 | +# Create a pending key and a 90-day certificate for the management node. |
| 49 | +--exec $NDB_SIGN_KEYS --create-key --pending -n 3 --schedule=70,5,80,5,90,0 |
| 50 | +--file_exists $MYSQLTEST_VARDIR/mysql_cluster.1/ndb-mgm-server-pending-key |
| 51 | +--file_exists $MYSQLTEST_VARDIR/mysql_cluster.1/ndb-mgm-server-pending-cert |
| 52 | + |
| 53 | +# Promote the files from pending to active |
| 54 | +--exec $NDB_SIGN_KEYS --promote -n 3 |
| 55 | + |
| 56 | +# Now the files have been renamed from pending to active |
| 57 | +--file_exists $MYSQLTEST_VARDIR/mysql_cluster.1/ndb-mgm-server-private-key |
| 58 | +--file_exists $MYSQLTEST_VARDIR/mysql_cluster.1/ndb-mgm-server-cert |
| 59 | + |
| 60 | +# The old pending files do not exist |
| 61 | +--error 1 |
| 62 | +--file_exists $MYSQLTEST_VARDIR/mysql_cluster.1/ndb-mgm-server-pending-key |
| 63 | +--error 1 |
| 64 | +--file_exists $MYSQLTEST_VARDIR/mysql_cluster.1/ndb-mgm-server-pending-cert |
| 65 | + |
| 66 | +# Create an active key and certificate for a data node, with bound node id |
| 67 | +--exec $NDB_SIGN_KEYS --create-key -n 2 |
| 68 | +--file_exists $MYSQLTEST_VARDIR/mysql_cluster.1/ndb-data-node-private-key |
| 69 | +--file_exists $MYSQLTEST_VARDIR/mysql_cluster.1/ndb-data-node-cert |
| 70 | + |
| 71 | +# Create a pending client key and cert in no-config mode |
| 72 | +--exec $NDB_SIGN_KEYS --no-config --create-key --pending -t api --bind-host=0 |
| 73 | +--file_exists $MYSQLTEST_VARDIR/mysql_cluster.1/ndb-api-pending-key |
| 74 | +--file_exists $MYSQLTEST_VARDIR/mysql_cluster.1/ndb-api-pending-cert |
| 75 | + |
| 76 | +# Then promote the pending files to active |
| 77 | +--exec $NDB_SIGN_KEYS --no-config -t api --promote |
| 78 | + |
| 79 | +# Remove them |
| 80 | +--chmod 0600 $MYSQLTEST_VARDIR/mysql_cluster.1/ndb-api-private-key |
| 81 | +--remove_file $MYSQLTEST_VARDIR/mysql_cluster.1/ndb-api-private-key |
| 82 | +--remove_file $MYSQLTEST_VARDIR/mysql_cluster.1/ndb-api-cert |
| 83 | + |
| 84 | +# Try to create a CSR for node 10. |
| 85 | +# There is not a node 10 configured, so this fails. |
| 86 | +--error 110 |
| 87 | +--exec $NDB_SIGN_KEYS -n 10 --create-key --skip-sign |
| 88 | + |
| 89 | +# Try to create a CSR for node 10 in no-config mode. |
| 90 | +# This fails because -n and no-config mode are incompatible |
| 91 | +--error 101 |
| 92 | +--exec $NDB_SIGN_KEYS -l -n 10 -t api --create-key --skip-sign |
| 93 | + |
| 94 | +# Try to create a CSR for an API node in no-config mode. |
| 95 | +# This fails because it wants to bind a hostname, but none is available. |
| 96 | +--error 34 |
| 97 | +--exec $NDB_SIGN_KEYS -l -t api --create-key --skip-sign |
| 98 | + |
| 99 | +# Create the CSR for an API node in no-config mode. |
| 100 | +--exec $NDB_SIGN_KEYS -l -t api --create-key --skip-sign --bind-host=0 |
| 101 | +--file_exists $MYSQLTEST_VARDIR/mysql_cluster.1/ndb-api-cert-request |
| 102 | + |
| 103 | +# Test remote key signing with a tool |
| 104 | +# (using ndb_sign_keys itself as the tool) |
| 105 | +# Because the CSR already exists, the binding options are not necessary. |
| 106 | +--let $cmd = `SELECT substring_index("$NDB_SIGN_KEYS", " ", 1)` |
| 107 | +--exec $NDB_SIGN_KEYS -l -t api -X $cmd >> $MYSQLTEST_VARDIR/tmp/rsk.out |
| 108 | +--remove_file $MYSQLTEST_VARDIR/tmp/rsk.out |
| 109 | +--file_exists $MYSQLTEST_VARDIR/mysql_cluster.1/ndb-api-cert |
| 110 | +--error 1 |
| 111 | +--file_exists $MYSQLTEST_VARDIR/mysql_cluster.1/ndb-api-cert-request |
| 112 | + |
| 113 | +# Refresh the certificate for node 2, but keep the existing key |
| 114 | +--exec $NDB_SIGN_KEYS -n 2 --schedule=70,5,80,5,90,0 |
| 115 | +--file_exists $MYSQLTEST_VARDIR/mysql_cluster.1/ndb-data-node-retired-cert |
| 116 | +--error 1 |
| 117 | +--file_exists $MYSQLTEST_VARDIR/mysql_cluster.1/ndb-data-node-retired-key |
| 118 | + |
| 119 | +# Check all the certs in the path, in no-config mode. |
| 120 | +--error 1 |
| 121 | +--exec $NDB_SIGN_KEYS --no-config --check --replace-by=-91 |
| 122 | + |
| 123 | +# Check all the certs in the path, using config |
| 124 | +--error 1 |
| 125 | +--exec $NDB_SIGN_KEYS --check --replace-by=-91 |
| 126 | + |
| 127 | +# Check the key cert node 3, using config (check passes) |
| 128 | +--exec $NDB_SIGN_KEYS --check --replace-by=-50 -n 3 |
| 129 | + |
| 130 | +# Check the cert for node 3, using config (check fails) |
| 131 | +--error 1 |
| 132 | +--exec $NDB_SIGN_KEYS --check --replace-by=-91 -n 3 |
| 133 | + |
| 134 | +# Replace the key and the certificate both |
| 135 | +--exec $NDB_SIGN_KEYS --create-key -n 3 |
| 136 | + |
| 137 | +# Rotate the CA |
| 138 | +--exec $NDB_SIGN_KEYS --rotate-CA |
| 139 | + |
| 140 | +# On Windows, private key files must be made writable to be removed. |
| 141 | +--chmod 0600 $MYSQLTEST_VARDIR/mysql_cluster.1/NDB-Cluster-private-key |
| 142 | +--chmod 0600 $MYSQLTEST_VARDIR/mysql_cluster.1/NDB-Cluster-private-key.retired |
| 143 | +--chmod 0600 $MYSQLTEST_VARDIR/mysql_cluster.1/ndb-data-node-private-key |
| 144 | +--chmod 0600 $MYSQLTEST_VARDIR/mysql_cluster.1/ndb-mgm-server-private-key |
| 145 | +--chmod 0600 $MYSQLTEST_VARDIR/mysql_cluster.1/ndb-api-private-key |
| 146 | + |
| 147 | +# Delete everything so the test can be repeated |
| 148 | +--remove_file $MYSQLTEST_VARDIR/mysql_cluster.1/NDB-Cluster-private-key |
| 149 | +--remove_file $MYSQLTEST_VARDIR/mysql_cluster.1/NDB-Cluster-cert |
| 150 | +--remove_file $MYSQLTEST_VARDIR/mysql_cluster.1/NDB-Cluster-private-key.retired |
| 151 | +--remove_file $MYSQLTEST_VARDIR/mysql_cluster.1/NDB-Cluster-cert.retired |
| 152 | +--remove_file $MYSQLTEST_VARDIR/mysql_cluster.1/ndb-data-node-private-key |
| 153 | +--remove_file $MYSQLTEST_VARDIR/mysql_cluster.1/ndb-data-node-cert |
| 154 | +--remove_file $MYSQLTEST_VARDIR/mysql_cluster.1/ndb-data-node-retired-cert |
| 155 | +--remove_file $MYSQLTEST_VARDIR/mysql_cluster.1/ndb-mgm-server-cert |
| 156 | +--remove_file $MYSQLTEST_VARDIR/mysql_cluster.1/ndb-mgm-server-private-key |
| 157 | +--remove_file $MYSQLTEST_VARDIR/mysql_cluster.1/ndb-mgm-server-retired-cert |
| 158 | +--remove_file $MYSQLTEST_VARDIR/mysql_cluster.1/ndb-api-private-key |
| 159 | +--remove_file $MYSQLTEST_VARDIR/mysql_cluster.1/ndb-api-cert |
0 commit comments