Skip to content

MDEV-39218: Master_ssl_verify_server_cert value is not set correctly#4880

Open
gengtianuiowa wants to merge 1 commit intoMariaDB:12.3from
gengtianuiowa:fix_master_ssl_cert
Open

MDEV-39218: Master_ssl_verify_server_cert value is not set correctly#4880
gengtianuiowa wants to merge 1 commit intoMariaDB:12.3from
gengtianuiowa:fix_master_ssl_cert

Conversation

@gengtianuiowa
Copy link
Copy Markdown
Contributor

@gengtianuiowa gengtianuiowa commented Mar 30, 2026

Description

In MariaDB 12.3.1, MariaDB made this change to refactor ssl_verify_server_cert to master_ssl_verify_server_cert in commit 89bd6b0.

However, these values are different types. While ssl_verify_server_cert is my_bool type, the master_ssl_verify_server_cert is trilean type which accepts three possible values (Yes/No/Default). When reading the value of the argument using !(my_bool)arg in mysql_options, trilean type value can't be retrieved because it accesses the wrong memory address by just passing the master_ssl_verify_server_cert, causing the master_ssl_verify_server_cert still behaves as "ON" when it's set to "OFF".

This commit changes the implementation to master_ssl_verify_server_cert.value to retrieve the correct value.

All new code of the whole pull request, including one or several files that are either new files or modified ones, are contributed under the BSD-new license. I am contributing on behalf of my employer Amazon Web Services, Inc.

How can this PR be tested?

Execute MTR test rpl_ssl_verify_server_cert_trilean_bug in the rpl suite.

Basing the PR against the correct MariaDB version

  • This is a new feature and the PR is based against the latest MariaDB development branch

Backward compatibility

This is a fix for the bug which only exists in 12.3 version. It's shouldn't be back-ported because they don't have the similar issue.

Copyright

All new code of the whole pull request, including one or several files that are either new files or modified ones, are contributed under the BSD-new license. I am contributing on behalf of my employer Amazon Web Services, Inc.

Copy link
Copy Markdown
Contributor

@ParadoxV5 ParadoxV5 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch!
How did this slip past both CI and QA 🤦?

I’m not sure about the new tests, complete with new certificate files.
It’d be quite a disappointment if the repo really not have any SSL replication test.

Comment on lines +1616 to +1618
*/
mysql_options(mysql, MYSQL_OPT_SSL_VERIFY_SERVER_CERT,
&mi->master_ssl_verify_server_cert);
&mi->master_ssl_verify_server_cert.value);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I recall MYSQL_OPT_SSL_VERIFY_SERVER_CERT (i.e., client flag --ssl-verify-server-cert) expects a boolean, so it should be

Suggested change
*/
mysql_options(mysql, MYSQL_OPT_SSL_VERIFY_SERVER_CERT,
&mi->master_ssl_verify_server_cert);
&mi->master_ssl_verify_server_cert.value);
*/
bool ssl_verify_server_cert= mi->master_ssl_verify_server_cert;
mysql_options(mysql, MYSQL_OPT_SSL_VERIFY_SERVER_CERT,
&ssl_verify_server_cert);

as MDEV-28302 intended.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How did this slip past both CI and QA 🤦?

I read through part of the existing tests. It's easy for this issue to slip through the existing tests because the current tests only verify the response after running show replica status;. In the result, the Master_SSL_Verify_Server_Cert still shows the right (YES/NO) value because the logic for parsing the YES/NO value seems different than the value retrieval mentioned here.

The new implementation should be the same as the current implementation if there are only two possible values. Even though the default value (-1) is picked, !*(my_bool*) arg will convert it to false, which is the same as passing YES. This is consistent with the current default of turning on Master_SSL_Verify_Server_Cert by default.

@ParadoxV5 ParadoxV5 requested review from bnestere and gkodinov March 30, 2026 19:59
@ParadoxV5 ParadoxV5 added External Contribution All PRs from entities outside of MariaDB Foundation, Corporation, Codership agreements. Replication Patches involved in replication labels Mar 30, 2026
@gkodinov gkodinov changed the title Fix bug where master_ssl_verify_server_cert value is not set correctl… Master_ssl_verify_server_cert value is not set correctly Mar 31, 2026
@gkodinov gkodinov changed the title Master_ssl_verify_server_cert value is not set correctly MDEV-38010: Master_ssl_verify_server_cert value is not set correctly Mar 31, 2026
@gkodinov gkodinov changed the title MDEV-38010: Master_ssl_verify_server_cert value is not set correctly MDEV-39218: Master_ssl_verify_server_cert value is not set correctly Mar 31, 2026
Copy link
Copy Markdown
Member

@gkodinov gkodinov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your contribution! This is a preliminary review.

LGTM. Please work with the current reviewers towards the final one.

Copy link
Copy Markdown
Contributor

@bnestere bnestere left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @gengtianuiowa !

Thank you for the contribution! I wasn't able to get your test to run locally (see my comment). Once that is addressed, I will provide another round of review.

@@ -0,0 +1,3 @@
--ssl-ca=$MYSQL_TEST_DIR/std_data/expired-ca-cert.pem
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't guaranteed to work across all environments. Many SSL libraries validate the certificate at server startup time (in mysqld_main() -> init_ssl()), and if the cert is expired, the server will fail to start.

Perhaps instead we can use the DEBUG_DBUG mechanism to simulate an expired certificate during checking. You can see existing examples of DEBUG_DBUG like this by grepping for:

  1. grep -ri "DEBUG_DBUG" ./sql
  2. grep -ri "debug_dbug=\"+d" ./mysql-test/suite/rpl/t

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Made the change based on this suggestion.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about we reword the filename and description a bit, so this test verifies master_ssl_verify_server_cert=0 in general, not just a specific bug?

Copy link
Copy Markdown
Contributor Author

@gengtianuiowa gengtianuiowa Apr 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reworded the file name and description

…y on replica

In the major release of MariaDB 12.3.1, MariaDB this change to
refactor ssl_verify_server_cert to master_ssl_verify_server_cert in
commit in 89bd6b0.

However, these values are different types. While ssl_verify_server_cert
is my_bool
type, the master_ssl_verify_server_cert is trilean type which accepts
three possible values (Yes/No/Default). When reading the value of the
argument using !*(my_bool*)arg in mysql_options, trilean type value
can't be retrieved because it accesses the wrong memory address by just
passing the master_ssl_verify_server_cert, causing the
master_ssl_verify_server_cert still behaves as "ON" when it's set to
"OFF".

This commit changes the implementation to
`master_ssl_verify_server_cert.value` retrieve the correct value.

All new code of the whole pull request, including one or several files
that are either new files or modified ones, are contributed under the
BSD-new license. I am contributing on behalf of my employer Amazon Web
Services, Inc.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

External Contribution All PRs from entities outside of MariaDB Foundation, Corporation, Codership agreements. Replication Patches involved in replication

Development

Successfully merging this pull request may close these issues.

4 participants