我正在尝试使用DBI
和连接SSL客户端密钥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', '' );
我收到以下错误:
Can't connect to database: missing "=" after "with\spaces.crt" in connection info string!
我试过在值周围使用单引号或双引号无效,我在文档中找不到任何内容.
更新单引号如下:
my $dsn = "dbi:Pg:db=mydb;sslmode=require;host=localhost;" ."sslcert='C:\\path with\\spaces.crt';" ."sslkey='C:\\path with\\spaces.key'";
我收到以下错误:
failed: FATAL: connection requires a valid client certificate
我知道这个配置有效,因为它适用于Python.
事实证明这是有效的:
my $dsn = "dbi:Pg:db=mydb;sslmode=require;host=localhost;" ."sslcert='C:\\\\path with\\\\spaces.crt';" ."sslkey='C:\\\\path with\\\\spaces.key'";
为什么我需要双逃逸反斜杠?