Ben*_*ock 3 verification perl ssl lwp-useragent
我想使用SSL_ca_pathssl选项,因为它更可靠.问题是它不使用给定目录中的证书.
此代码有效:
local $NET::HTTPS::SSL_SOCKET_CLASS = 'IO::Socket::SSL';
my $ua = LWP::UserAgent->new(ssl_opts => {
SSL_ca_file => "/etc/pki/tls/certs/ca-bundle.crt",
# SSL_ca_path => "/etc/pki/tls/certs/",
});
Run Code Online (Sandbox Code Playgroud)
但使用SSL_ca_path而不是SSL_ca_file打破脚本.
不工作
local $NET::HTTPS::SSL_SOCKET_CLASS = 'IO::Socket::SSL';
my $ua = LWP::UserAgent->new(ssl_opts => {
# SSL_ca_file => "/etc/pki/tls/certs/ca-bundle.crt",
SSL_ca_path => "/etc/pki/tls/certs/",
});
Run Code Online (Sandbox Code Playgroud)
既不将证书重命名为*.pem也不删除/路径中的尾部都可以解决问题.
目录和文件的权限和所有者是相同的(770)
完整的脚本:https://github.com/Benedikt1992/nagios-jenkins-plugin/blob/master/check_jenkins_job_extended.pl#L71-L75
与OpenSSL一起使用的证书目录(IO :: Socket :: SSL使用的TLS实现)需要具有特定的结构,其中文件名基于证书主题的哈希值.这意味着仅仅删除目录中的证书是不够的.
例如,您将找到以下结构(取自Ubuntu /etc/ssl/certs):
lrwxrwxrwx 1 root root 41 Feb 25 10:19 f30dd6ad.0 -> USERTrust_ECC_Certification_Authority.pem
lrwxrwxrwx 1 root root 34 Feb 25 10:19 f3377b1b.0 -> Security_Communication_Root_CA.pem
Run Code Online (Sandbox Code Playgroud)
可以使用OpenSSL rehash或c_rehash命令创建此目录结构.该命令创建开始与散列(在的OpenSSL一些版本中,可以使用下式计算符号链接openssl x509 -noout -hash -in <certfile>),随后一个句号和一个数字(开始.0,并使用.1,.2,.3等.如果多个证书具有相同的哈希值).注意:对于不同版本的OpenSSL,名称的哈希计算可能会有所不同.
| 归档时间: |
|
| 查看次数: |
1014 次 |
| 最近记录: |