Skip to content

Commit 58e017b

Browse files
committed
Fix for fetching pubkey when building against 8.0
This is tesed with: - Compiled and ran with 8.0.18 libraries - Server running with 8.0.17 - Account using `caching_sha2` auth The problem is this: We check if `MYSQL_OPT_GET_SERVER_PUBLIC_KEY` is defined. This is expected to succeed on 8.0.18, but it is not. Now replacing it with a version check. To test: ``` use v5.30.0; use DBI; my $dbh = DBI->connect("DBI:mysql:host=127.0.0.1;port=8017;database=test;mysql_ssl=0;mysql_get_server_pubkey=1", "msandbox", "msandbox", {'RaiseError' => 1}); my $sth = $dbh->prepare('SHOW SESSION STATUS LIKE "Ssl_cipher"'); $sth->execute(); while (my $row = $sth->fetchrow_arrayref()) { say $row->[0] . " = " . $row->[1]; } $sth->finish(); $dbh->disconnect(); ``` Use `RESTART` to restart the server to ensure you are not using the caching features of `caching_sha2`. * With `mysql_ssl=0;mysql_get_server_pubkey=0` the connection should fail. * With `mysql_ssl=0;mysql_get_server_pubkey=1` the connection should succeed, with no SSL cipher shown. * With `mysql_ssl=1;mysql_get_server_pubkey=0` the connection should succeed, with a SSL cipher shown. * With `mysql_ssl=1;mysql_get_server_pubkey=1` the connection should succeed, with a SSL cipher shown.
1 parent e6312de commit 58e017b

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

dbdimp.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -1909,7 +1909,7 @@ MYSQL *mysql_dr_connect(
19091909
}
19101910

19111911
#ifndef MARIADB_BASE_VERSION
1912-
#ifdef MYSQL_OPT_GET_SERVER_PUBLIC_KEY
1912+
#if (MYSQL_VERSION_ID >= 80011)
19131913
if ((svp = hv_fetch(hv, "mysql_get_server_pubkey", 23, FALSE)) && *svp && SvTRUE(*svp)) {
19141914
my_bool server_get_pubkey = 1;
19151915
mysql_options(sock, MYSQL_OPT_GET_SERVER_PUBLIC_KEY, &server_get_pubkey);

0 commit comments

Comments
 (0)