I've got this working on the Unix-y platforms, but of course Windows is giving me issues.
Using File::Temp to write the certs to the filesystem works just fine, but when I try to pass them in as a connection string with $file_temp->filename, the drive letter is stripped and the path is, in general, unusable.
For example, if I write the cert out using:
my $mysql_ssl_ca_fh = File::Temp->new( UNLINK => 1, SUFFIX => '.pem');
my $mysql_ssl_ca_file = $mysql_ssl_ca_fh->filename;
print $mysql_ssl_ca_fh $SSL_CA_FILE_STRING;
I'll get a randomly-named file (for the purpose of this post, let's call it "foo.pem") in C:\ that contains the contents of $SSL_CA_FILE_STRING.
However, when I try to read it back in, like so:
sub dbconnect {
my $engine = shift;
my $dsn
= q{dbi:mysql:database=database;}
. q{host=} . $engine
. q{;port=3306}
. q{;mysql_ssl=1}
. q{;mysql_ssl_ca_file=} . $mysql_ssl_ca_file
. q{;mysql_ssl_client_cert=} . $mysql_ssl_cert_file
. q{;mysql_ssl_client_key=} . $mysql_ssl_key_file
. q{;mysql_ssl_cipher=} . $SSL_CIPHER;
my $dbuser = q{supportclient};
my $dbpw = q{};
my $dbh = DBI->connect( $dsn, $dbuser, $dbpw ) || confess;
return $dbh;
}
I would expect $mysql_ssl_ca_file to contain the value "C:\foo.pem", but it instead contains "\foo.pem", so perhaps File::Temp isn't compatible with Windows paths. Not that it matters. When I try to debug the DSN connection string using dbish, as I normally do, it doesn't seem to understand Windows paths either, so I'm at a loss.
Anyone have any suggestions for how I can create a path to a file on a Windows filesystem that will work in a DBD::mysql DSN? It's not clear from the docs (or maybe I'm not looking in the right place) what the expected format is. The only thing that seems to work (dbish-wise) is being in the same directory as the cert files, and not using any paths.
|