I'm trying to connect with an SSL client key using DBI
and DBD::Pg
.
use strict;
use warnings 'all';
use DBI;
my $dsn = "dbi:Pg:db=mydb;sslmode=require;host=localhost;"
."sslcert=C:\\path with\\spaces.crt;"
."sslkey=C:\\path with\\spaces.key";
my $dbh = DBI->connect( $dsn, 'username', '' );
I get the following error:
Can't connect to database: missing "=" after "with\spaces.crt" in connection info string!
I have tried using single or double quotes around the values to no avail, and I can't find anything in the documentation.
Update
With single quotes as follows:
my $dsn = "dbi:Pg:db=mydb;sslmode=require;host=localhost;"
."sslcert='C:\\path with\\spaces.crt';"
."sslkey='C:\\path with\\spaces.key'";
I get the following error:
failed: FATAL: connection requires a valid client certificate
I know that this configuration works, as it works in Python.
It turns out that this works:
my $dsn = "dbi:Pg:db=mydb;sslmode=require;host=localhost;"
."sslcert='C:\\\\path with\\\\spaces.crt';"
."sslkey='C:\\\\path with\\\\spaces.key'";
Why do I need double escaped backslashes?