Unsupported workaround if the DBD::MySQL driver fails to establish a TLS-encrypted connection to MySQL servers with caching_sha2_password enabled
Environment
- Red Hat Enterprise Linux 9
Issue
Perl applications fail to establish a connection if all of the following conditions are met:
- The application connects to a MySQL 8 server.
- The
caching_sha2_passwordoption is enabled in the MySQL server configuration. - The connection uses the
DBI->connect with mysql_ssl=1option.
If the problem appears, Perl displays an error, such as failed: SSL connection error: Enforcing SSL encryption is not supported.
This bug is tracked in the This content is not included.RHEL-77083 ticket.
Resolution
The following is an unsupported workaround:
-
Remove the perl-DBD-MySQL package:
# dnf remove perl-DBD-MySQL -
Enable the codeready builder repository for your platform:
# subscription-manager repos --enable codeready-builder-for-rhel-9-$(arch)-rpms -
Install the dependencies that are required to compile the driver:
# dnf install mysql-devel perl-Devel-CheckLib perl-DBI -
Download the
DBD-mysqlpackage from CPAN, for example:# wget https://cpan.metacpan.org/authors/id/D/DV/DVEEDEN/DBD-mysql-4.050.tar.gz -
Unpack the archive:
# tar xvfz DBD-mysql-4.050.tar.gz -
Change into the directory with the extracted source code:
# cd DBD-mysql-4.050 -
Create the Makefile:
# perl Makefile.PL -
Compile the driver:
# make -
Install the driver:
# make install
Note that Red Hat does not support this workaround and the self-compiled DBD::mysql driver will not be updated from RHEL repositories.
Verification
You can use the following code snippet to verify the DBD::mysql driver:
#!/usr/bin/perl
use strict;
use warnings;
use DBI;
my $hostname = '127.0.0.1';
my $database = 'mysql';
my $port = 3306;
my $dsn = "DBI:mysql:database=$database;host=$hostname;port=$port";
my $dbi = DBI->connect($dsn, '<username>', '<password>', {'mysql_ssl' => 1});
if (! defined $dbi)
exit;
}
my $ret = $dbi->ping;
print "$ret\n";
Root Cause
The perl-DBD-MySQL package is incorrectly linked against the libmariadb library.
This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.