Percona renew ssl certificate

Hello here,

I Have modified my certificate on all my 3 nodes by setting this on the file my.cnf

wsrep_provider_options = "socket.ssl=yes;socket.ssl_key=/etc/mysql/ssl/server.key;socket.ssl_cert=/etc/mysql/ssl/server.crt;socket.ssl_ca=/etc/mysql/ssl/ca.crt"

[sst]
encrypt=4
ssl-key=/etc/mysql/ssl/server.key
ssl-ca=/etc/mysql/ssl/ca.crt
ssl-cert=/etc/mysql/ssl/server.crt

But when I look at the variable I still have the old file name.

| ssl_ca                              | ca.pem          |
| ssl_capath                          |                 |
| ssl_cert                            | server-cert.pem |
| ssl_cipher                          |                 |
| ssl_crl                             |                 |
| ssl_crlpath                         |                 |
| ssl_fips_mode                       | OFF             |
| ssl_key                             | server-key.pem  |

How can i proceed for the renewal of certificate to take affect ?

Best regards,

Hello Diogene_Mutombo,

After making this changed in my.cnf it’s require to restart mysql to apply this changes, please let me know if restart of the mysql service was made?

Note that in MySQL 8 we have ALTER INSTANCE RELOAD TLS; which doesn’t require mysql restart. (ref)

Regards,
Denis Subbota.
Managed Services, Percona.

Hello Denis_Subbota,

Yes, I have restarted mysql on all 3 nodes.
I am going to try the ALTER command.

best regards,

No luck, I still have the same old filename.

mysql> ALTER INSTANCE RELOAD TLS;

mysql> show variables like '%ssl%';
+-------------------------------------+-----------------+
| Variable_name                       | Value           |
+-------------------------------------+-----------------+
| admin_ssl_ca                        |                 |
| admin_ssl_capath                    |                 |
| admin_ssl_cert                      |                 |
| admin_ssl_cipher                    |                 |
| admin_ssl_crl                       |                 |
| admin_ssl_crlpath                   |                 |
| admin_ssl_key                       |                 |
| have_openssl                        | YES             |
| have_ssl                            | YES             |
| mysqlx_ssl_ca                       |                 |
| mysqlx_ssl_capath                   |                 |
| mysqlx_ssl_cert                     |                 |
| mysqlx_ssl_cipher                   |                 |
| mysqlx_ssl_crl                      |                 |
| mysqlx_ssl_crlpath                  |                 |
| mysqlx_ssl_key                      |                 |
| performance_schema_show_processlist | OFF             |
| ssl_ca                              | ca.pem          |
| ssl_capath                          |                 |
| ssl_cert                            | server-cert.pem |
| ssl_cipher                          |                 |
| ssl_crl                             |                 |
| ssl_crlpath                         |                 |
| ssl_fips_mode                       | OFF             |
| ssl_key                             | server-key.pem  |
| ssl_session_cache_mode              | ON              |
| ssl_session_cache_timeout           | 300             |
+-------------------------------------+-----------------+

For info, I usign these mysql version and wsrep version
Server version: 8.0.32-24.1 Percona XtraDB Cluster (GPL), Release rel24, Revision 793b5d9, WSREP version 26.1.4.3

Hello Diogene,

Can you check your error log. They should tell you something about .key files that you’re assigning. I believe you need to use pem files instead of key / crt.

Thanks,
Kedar.

Hello Kerdar,

In the log I have only the problem concerning SSL Handshake. I am wondering why.

2023-05-29T01:48:09.800046Z 0 [Warning] [MY-000000] [Galera] Handshake failed: version too low
2023-05-29T01:48:10.236444Z 0 [Warning] [MY-000000] [Galera] Handshake failed: peer did not return a certificate
2023-05-29T01:50:33.471324Z 0 [Warning] [MY-000000] [Galera] Handshake failed: peer did not return a certificate
2023-05-29T01:52:51.183247Z 0 [Warning] [MY-000000] [Galera] Handshake failed: peer did not return a certificate
2023-05-29T01:52:52.518185Z 0 [Warning] [MY-000000] [Galera] Handshake failed: peer did not return a certificate
2023-05-29T01:52:52.669347Z 0 [Warning] [MY-000000] [Galera] Handshake failed: peer did not return a certificate
2023-05-29T01:52:52.757302Z 0 [Warning] [MY-000000] [Galera] Handshake failed: peer did not return a certificate
2023-05-29T01:52:56.146399Z 0 [Warning] [MY-000000] [Galera] Handshake failed: peer did not return a certificate
2023-05-29T01:53:01.177309Z 0 [Warning] [MY-000000] [Galera] Handshake failed: peer did not return a certificate
2023-05-29T01:53:06.206217Z 0 [Warning] [MY-000000] [Galera] Handshake failed: peer did not return a certificate
2023-05-29T01:53:11.210617Z 0 [Warning] [MY-000000] [Galera] Handshake failed: peer did not return a certificate
2023-05-29T01:53:16.139371Z 0 [Warning] [MY-000000] [Galera] Handshake failed: peer did not return a certificate
2023-05-29T01:54:26.114475Z 0 [Warning] [MY-000000] [Galera] Handshake failed: peer did not return a certificate
2023-05-29T01:54:30.402854Z 0 [Warning] [MY-000000] [Galera] Handshake failed: unexpected message
2023-05-29T01:54:30.533716Z 0 [Warning] [MY-000000] [Galera] Handshake failed: unexpected message
2023-05-29T01:57:44.665170Z 0 [Warning] [MY-000000] [Galera] Handshake failed: peer did not return a certificate

I have renamed the file in .pem and reload the ssl config any luck still have the same old file.

mysql> ALTER INSTANCE RELOAD TLS;
Query OK, 0 rows affected (0.00 sec)

| performance_schema_show_processlist | OFF             |
| ssl_ca                              | ca.pem          |
| ssl_capath                          |                 |
| ssl_cert                            | server-cert.pem |
| ssl_cipher                          |                 |
| ssl_crl                             |                 |
| ssl_crlpath                         |                 |
| ssl_fips_mode                       | OFF             |
| ssl_key                             | server-key.pem  |
| ssl_session_cache_mode              | ON              |
| ssl_session_cache_timeout           | 300             |
+-------------------------------------+-----------------+
27 rows in set (0.00 sec)

The cluster is running OK

+----------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------[65/1819]
| wsrep_local_state_uuid           | 26f228c6-71ac-11ed-a8bc-7e43376c0c39                                                                                                           |
| wsrep_protocol_version           | 10                                                                                                                                             |
| wsrep_last_applied               | 135235                                                                                                                                         |
| wsrep_last_committed             | 135235                                                                                                                                         |
| wsrep_monitor_status (L/A/C)     | [ (10, 10), (135235, 135235), (135235, 135235) ]                                                                                               |
| wsrep_replicated                 | 0                                                                                                                                              |
| wsrep_replicated_bytes           | 0                                                                                                                                              |
| wsrep_repl_keys                  | 0                                                                                                                                              |
| wsrep_repl_keys_bytes            | 0                                                                                                                                              |
| wsrep_repl_data_bytes            | 0                                                                                                                                              |
| wsrep_repl_other_bytes           | 0                                                                                                                                              |
| wsrep_received                   | 10                                                                                                                                             |
| wsrep_received_bytes             | 1034                                                                                                                                           |
| wsrep_local_commits              | 0                                                                                                                                              |
| wsrep_local_cert_failures        | 0                                                                                                                                              |
| wsrep_local_replays              | 0                                                                                                                                              |
| wsrep_local_send_queue           | 0                                                                                                                                              |
| wsrep_local_send_queue_max       | 1
| wsrep_local_send_queue_min       | 0                                                                                                                                              |
| wsrep_local_send_queue_avg       | 0                                                                                                                                              |
| wsrep_local_recv_queue           | 0                                                                                                                                              |
| wsrep_local_recv_queue_max       | 2                                                                                                                                              |
| wsrep_local_recv_queue_min       | 0                                                                                                                                              |
| wsrep_local_recv_queue_avg       | 0.1                                                                                                                                            |
| wsrep_local_cached_downto        | 121830                                                                                                                                         |
| wsrep_flow_control_paused_ns     | 0                                                                                                                                              |
| wsrep_flow_control_paused        | 0                                                                                                                                              |
| wsrep_flow_control_sent          | 0                                                                                                                                              |
| wsrep_flow_control_recv          | 0                                                                                                                                              |
| wsrep_flow_control_active        | false                                                                                                                                          |
| wsrep_flow_control_requested     | false                                                                                                                                          |
| wsrep_flow_control_interval      | [ 173, 173 ]                                                                                                                                   |
| wsrep_flow_control_interval_low  | 173
| wsrep_flow_control_interval_high | 173                                                                                                                                            |
| wsrep_flow_control_status        | OFF                                                                                                                                            |
| wsrep_cert_deps_distance         | 0                                                                                                                                              |
| wsrep_apply_oooe                 | 0                                                                                                                                              |
| wsrep_apply_oool                 | 0                                                                                                                                              |
| wsrep_apply_window               | 0                                                                                                                                              |
| wsrep_apply_waits                | 0                                                                                                                                              |
| wsrep_commit_oooe                | 0                                                                                                                                              |
| wsrep_commit_oool                | 0                                                                                                                                              |
| wsrep_commit_window              | 0                                                                                                                                              |
| wsrep_local_state                | 4                                                                                                                                              |
| wsrep_local_state_comment        | Synced                                                                                                                                         |
| wsrep_cert_index_size            | 0                                                                                                                                              |
| wsrep_cert_bucket_count          | 1                                                                                                                                              |
| wsrep_gcache_pool_size           | 30681928
| wsrep_causal_reads               | 0                                                                                                                                              |
| wsrep_cert_interval              | 0                                                                                                                                              |
| wsrep_open_transactions          | 0                                                                                                                                              |
| wsrep_open_connections           | 0                                                                                                                                              |
| wsrep_ist_receive_status         |                                                                                                                                                |
| wsrep_ist_receive_seqno_start    | 0                                                                                                                                              |
| wsrep_ist_receive_seqno_current  | 0                                                                                                                                              |
| wsrep_ist_receive_seqno_end      | 0                                                                                                                                              |
| wsrep_incoming_addresses         |IPNODE1:3306,IPNODE2:3306,IPNODE3:3306                                                                                       |
| wsrep_cluster_weight             | 3                                                                                                                                              |
| wsrep_desync_count               | 0                                                                                                                                              |
| wsrep_evs_delayed                |                                                                                                                                                |
| wsrep_evs_evict_list             |                                                                                                                                                |
| wsrep_evs_repl_latency           | 0/0/0/0/0                                                                                                                                      |
| wsrep_evs_state                  | OPERATIONAL
| wsrep_cluster_weight             | 3                                                                                                                                              |
| wsrep_desync_count               | 0                                                                                                                                              |
| wsrep_evs_delayed                |                                                                                                                                                |
| wsrep_evs_evict_list             |                                                                                                                                                |
| wsrep_evs_repl_latency           | 0/0/0/0/0                                                                                                                                      |
| wsrep_evs_state                  | OPERATIONAL                                                                                                                                    |
| wsrep_gcomm_uuid                 | f1905002-fd63-11ed-af8d-4acb7bb754e3                                                                                                           |
| wsrep_gmcast_segment             | 0                                                                                                                                              |
| wsrep_cluster_capabilities       |                                                                                                                                                |
| wsrep_cluster_conf_id            | 3                                                                                                                                              |
| wsrep_cluster_size               | 3                                                                                                                                              |
| wsrep_cluster_state_uuid         | 26f228c6-71ac-11ed-a8bc-7e43376c0c39                                                                                                           |
| wsrep_cluster_status             | Primary                                                                                                                                        |
| wsrep_connected                  | ON                                                                                                                                             |
| wsrep_local_bf_aborts            | 0                                                                                                                                              |
| wsrep_local_index                | 2
| wsrep_provider_capabilities      | :MULTI_MASTER:CERTIFICATION:PARALLEL_APPLYING:TRX_REPLAY:ISOLATION:PAUSE:CAUSAL_READS:INCREMENTAL_WRITESET:UNORDERED:PREORDERED:STREAMING:NBO: |
| wsrep_provider_name              | Galera                                                                                                                                         |
| wsrep_provider_vendor            | Codership Oy <info@codership.com> (modified by Percona <https://percona.com/>)                                                                 |
| wsrep_provider_version           | 4.14(779b689)                                                                                                                                  |
| wsrep_ready                      | ON                                                                                                                                             |
| wsrep_thread_count               | 9                                                                                                                                              |
+----------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------+
79 rows in set (0.00 sec)

Here is my cnf
```shell
[client]
socket=/var/lib/mysql/mysql.sock

[mysqld]
server-id=1
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
log-bin=/var/lib/mysql/percona-pcx1-bin
log-bin-index=/var/lib/mysql/percona-pcx1-bin.index

# Binary log expiration period is 604800 seconds, which equals 7 days
binlog_expire_logs_seconds=604800

######## wsrep ###############
# Path to Galera library
wsrep_provider=/usr/lib64/galera4/libgalera_smm.so

# Cluster connection URL contains IPs of nodes
#If no IP is found, this implies that a new cluster needs to be created,
#in order to do that you need to bootstrap this node
wsrep_cluster_address=gcomm://IP NODE1,IP NODE2,IP NODE3

# In order for Galera to work correctly binlog format should be ROW
binlog_format=ROW

# Slave thread to use
wsrep_slave_threads=8

wsrep_log_conflicts

# This changes how InnoDB autoincrement locks are managed and is a requirement for Galera
innodb_autoinc_lock_mode=2

# Node IP address
wsrep_node_address=IP NODE 1
# Cluster name
wsrep_cluster_name=cluster

#If wsrep_node_name is not specified,  then system hostname will be used
wsrep_node_name=NODE NAME

#pxc_strict_mode allowed values: DISABLED,PERMISSIVE,ENFORCING,MASTER
pxc_strict_mode=ENFORCING
# SST method
wsrep_sst_method=xtrabackup-v2

#[mysqld]
wsrep_provider_options = "socket.ssl=yes;socket.ssl_key=/etc/mysql/ssl/serverkey.pem;socket.ssl_cert=/etc/mysql/ssl/server-crt.pem;socket.ssl_ca=/etc/mysql/ssl/ca.pem"

[sst]
encrypt=4
ssl-key=/etc/mysql/ssl/serverkey.pem
ssl-ca=/etc/mysql/ssl/ca.pem
ssl-cert=/etc/mysql/ssl/server-crt.pem

the SSL file are in this directory

ll /etc/mysql/ssl/ -trh
-rw-r--r-- 1 mysql mysql 1.3K May 29 13:03 ca.pem
-rw------- 1 mysql mysql 1.8K May 29 13:03 ca-key.pem
-rw-r--r-- 1 mysql mysql  993 May 29 13:03 server-csr.pem
-rw-r--r-- 1 mysql mysql 1.2K May 29 13:04 server-crt.pem
-rw------- 1 mysql mysql 1.7K May 29 13:05 serverkey.pem

I am still have this issue, Anyone to help ?

Shouldn’t those parameter names be with underscores?
ssl**_**key= …

etc.

Hi Diogene,

So you have PXC 8.0.32-24 and a working cluster. And you already have SSL encryption but want to replace the key files.
You should

  • generate ssl
  • have same certs on all nodes
  • restart mysql / reload ssl
  • update sst user to have REQUIRE SSL (mostly this is also already done)

I am not sure what you meant by “renamed the file in .pem”! I hope you mean using the “.pem” file instead of “.crt”/“.key”
What do you mean by “still have the same old file”? What are you expecting?
Also I see you say the “cluster is OK” and cluster node appears in “sync” state, though can you include the output of following:

show global variables like 'wsrep_provider_options'\G

Here are few links (which you might already have) for the task:

Thanks,
Kedar.

Hello,
I am not sure what you meant by “renamed the file in .pem” → mean using the .pem instead of .crt
All cert file are on the 3 nodes.
I have this on my cnf file

# SST method
wsrep_sst_method=xtrabackup-v2

#[mysqld]
wsrep_provider_options = "socket.ssl_key=/etc/mysql/ssl/serverkey.pem;socket.ssl_cert=/etc/mysql/ssl/server-crt.pem;socket.ssl_ca=/etc/mysql/ssl/ca.pem"

[sst]
encrypt=4
ssl-key=/etc/mysql/ssl/serverkey.pem
ssl-ca=/etc/mysql/ssl/ca.pem
ssl-cert=/etc/mysql/ss/server-crt.pem

The node are not starting no more

2023-05-30T10:11:59.963705Z 0 [ERROR] [MY-000000] [Galera] Failed to create a new provider '/usr/lib64/galera4/libgalera_smm.so' with options 'socket.ssl_key=/etc/mysql/ssl/serverkey.pem;socket.ssl_cert=/etc/mysql/ssl/server-crt.pem;socket.ssl_ca=/etc/mysql/ssl/ca.pem;socket.ssl_key=(null);socket.ssl_ca=(null);socket.ssl_cert=(null)': Failed to initialize wsrep provider
2023-05-30T10:11:59.963734Z 0 [ERROR] [MY-000000] [WSREP] Failed to load provider
2023-05-30T10:11:59.963779Z 0 [ERROR] [MY-010119] [Server] Aborting
2023-05-30T10:11:59.964103Z 0 [System] [MY-010910] [Server] /usr/sbin/mysqld: Shutdown complete (mysqld 8.0.32-24.1)  Percona XtraDB Cluster (GPL), Release rel24, Revision 793b5d9, WSREP version 26.1.4.3.
2023-05-30T10:11:59.964973Z 0 [ERROR] [MY-010065] [Server] Failed to shutdown components infrastructure.

@Diogene_Mutombo Try with parameter names changed to

ssl_key=
ssl_ca=
ssl_cert=

Here is the result of the command

mysql> show global variables like 'wsrep_provider_options' \G
*************************** 1. row ***************************
Variable_name: wsrep_provider_options
        Value: allocator.disk_pages_encryption = no; allocator.encryption_cache_page_size = 32K; allocator.encryption_cache_size = 16777216; base_dir = /var/lib/mysql/; base_host = 192.168.1.215; base_port = 4567; cert.log_conflicts = no; cert.optimistic_pa = no; debug = no; evs.auto_evict = 0; evs.causal_keepalive_period = PT1S; evs.debug_log_mask = 0x1; evs.delay_margin = PT1S; evs.delayed_keep_period = PT30S; evs.inactive_check_period = PT0.5S; evs.inactive_timeout = PT15S; evs.info_log_mask = 0; evs.install_timeout = PT7.5S; evs.join_retrans_period = PT1S; evs.keepalive_period = PT1S; evs.max_install_timeouts = 3; evs.send_window = 10; evs.stats_report_period = PT1M; evs.suspect_timeout = PT5S; evs.use_aggregate = true; evs.user_send_window = 4; evs.version = 1; evs.view_forget_timeout = P1D; gcache.dir = /var/lib/mysql/; gcache.encryption = no; gcache.encryption_cache_page_size = 32K; gcache.encryption_cache_size = 16777216; gcache.freeze_purge_at_seqno = -1; gcache.keep_pages_count = 0; gcache.keep_pages_size = 0; gcache.mem_size = 0; gcache.name = galera.cache; gcache.page_size = 128M; gcache.recover = yes; gcache.size = 128M; gcomm.thread_prio = ; gcs.fc_debug = 0; gcs.fc_factor = 1.0; gcs.fc_limit = 100; gcs.fc_master_slave = no; gcs.fc_single_primary = no; gcs.max_packet_size = 64500; gcs.max_throttle = 0.25; gcs.recv_q_hard_limit = 9223372036854775807; gcs.recv_q_soft_limit = 0.25; gcs.sync_donor = no; gmcast.listen_addr = ssl://0.0.0.0:4567; gmcast.mcast_addr = ; gmcast.mcast_ttl = 1; gmcast.peer_timeout = PT3S; gmcast.segment = 0; gmcast.time_wait = PT5S; gmcast.version = 0; ist.recv_addr = 192.168.1.215; pc.announce_timeout = PT3S; pc.checksum = false; pc.ignore_quorum = false; pc.ignore_sb = false; pc.linger = PT20S; pc.npvo = false; pc.recovery = true; pc.version = 0; pc.wait_prim = true; pc.wait_prim_timeout = PT30S; pc.weight = 1; protonet.backend = asio; protonet.version = 0; repl.causal_read_timeout = PT30S; repl.commit_order = 3; repl.key_format = FLAT8; repl.max_ws_size = 2147483647; repl.proto_max = 10; s
1 row in set (0.00 sec)

I make it work by naming the certs and key file like this:

-rw-r--r-- 1 mysql mysql      1196 May 30 11:40  server-cert.pem
-rw------- 1 mysql mysql      1679 May 30 11:40  server-key.pem
-rw-r--r-- 1 mysql mysql      1318 May 30 11:40  ca.pem

I don’t know why, it only accept these naming.
but thank you all for you help.

Do you guys know how to test SSL handshake within the cluster ?

best regards,

Hello,

From error log

2023-05-30T10:11:59.963705Z 0 [ERROR] [MY-000000] [Galera] Failed to create a new provider '/usr/lib64/galera4/libgalera_smm.so' with options 'socket.ssl_key=/etc/mysql/ssl/serverkey.pem;socket.ssl_cert=/etc/mysql/ssl/server-crt.pem;socket.ssl_ca=/etc/mysql/ssl/ca.pem;socket.ssl_key=(null);socket.ssl_ca=(null);socket.ssl_cert=(null)': Failed to initialize wsrep provider

this is OK:
socket.ssl_key=/etc/mysql/ssl/serverkey.pem;socket.ssl_cert=/etc/mysql/ssl/server-crt.pem;socket.ssl_ca=/etc/mysql/ssl/ca.pem;

but why do I see this?
socket.ssl_key=(null);socket.ssl_ca=(null);socket.ssl_cert=(null)'

Can you confirm you SSL configuration is OK?

Thanks,
K

I make it work by naming the certs and key file like this:

-rw-r--r-- 1 mysql mysql      1196 May 30 11:40  server-cert.pem
-rw------- 1 mysql mysql      1679 May 30 11:40  server-key.pem
-rw-r--r-- 1 mysql mysql      1318 May 30 11:40  ca.pem

It seems like, it only accept the name like this server-cert.pem and server-key.pem as the original cert created when mysql is initialize.

Keep ignoring my replies…
It’s because these are the default names and your configuration is ignored…

This variable is dynamic for this version and all it accepts is “FILENAME” which can be any thing
https://dev.mysql.com/doc/refman/8.0/en/server-system-variables.html#sysvar_ssl_cert
Is it possible that you have specified those file names somewhere in your config this way?

Also let’s see what @bitone is suggesting.

Hello @bitone

I don’t ignore, I am trying and let you know.
I know now why my configuration was ignored.

1 Like

Hello @bitone,

I have tried by changing the parameter as suggested but no luck

[sst] 
encrypt=4                                                                                             
ssl_key=/etc/mysql/ssl/server-key.pem                                                                 
ssl_ca=/etc/mysql/ssl/ca.pem                                                                          
ssl_cert=/etc/mysql/ssl/server-crt.pem 
wsrep_provider_options="socket.ssl_key=/etc/mysql/ssl/server-key.pem;socket.ssl_cert=/etc/mysql/ssl/server-crt.pem;socket.ssl_ca=/etc/mysql/ssl/ca.pem"

What mysql give me with this command

mysql> show variables like '%ssl%';
| performance_schema_show_processlist | OFF             |
| ssl_ca                              | ca.pem          |
| ssl_capath                          |                 |
| ssl_cert                            | server-cert.pem |
| ssl_cipher                          |                 |
| ssl_crl                             |                 |
| ssl_crlpath                         |                 |
| ssl_fips_mode                       | OFF             |
| ssl_key                             | server-key.pem  |
| ssl_session_cache_mode              | ON              |
| ssl_session_cache_timeout           | 300             |
+-------------------------------------+-----------------+

Well…

ssl_cert etc. certainly works for the server configuration, like:

[mysqld]
ssl_cert        = /etc/mysql/test.pm

and then

mysql> show variables like '%ssl%';
| ssl_cert                            | /etc/mysql/test.pm |

but when you put it under [sst]
then
mysql> show variables like '%ssl%';
still shows you the (default) server setting but not what you set for SST…

2 Likes