本文介绍了为什么 Zend 2 http 不验证我的 ssl 证书?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚开始使用 Zend 2,它(在本地)运行得非常好,但我无法让它通过 https 将数据传递到另一台服务器.

I've just started using Zend 2 and it works really well (locally) but I can't get it to pass data via https to another server.

在 ssl 证书方面我有点菜鸟,我认为这就是问题所在.我有一个 CERT、一个私钥和一个 CA 证书 - 这些被用于我们服务器上的一个 vhost 域上的 ssl 证书,位置是:-

I'm a bit of a noob when it comes to ssl certs and I think this is where the problem lies. I've got a CERT, a Private Key and a CA cert - these are being used for an ssl cert on one of our vhost domains on our server the locations are : -

SSLCertificateFile /usr/local/psa/var/certificates/cert-####
SSLCACertificateFile /usr/local/psa/var/certificates/cert-####

在我读到的每个示例中,它们都在/etc/ssl/certs/ca-bundle.pem"中.我的问题是如何将它们粘在一起以创建 zend 2 想要的这个 .pem 文件?我已经尝试创建一个 .pem 文件,其中包含所有 -----BEGIN CERTIFICATE----- 哈希/密钥 -----END CERTIFICATE----- 并将其命名为 ca-bundle.pem但现在 Apache 向我抛出无法设置验证位置"错误,我该如何让它工作?这是我为适配器编写的代码片段:-

In every example I read they're in '/etc/ssl/certs/ca-bundle.pem'. My question is how to I stick them together to create this .pem file that zend 2 wants? I've tried just creating a .pem file with all the -----BEGIN CERTIFICATE----- the hash/key -----END CERTIFICATE----- in and named it ca-bundle.pem but now Apache throws 'Unable to set verify locations' error at me, how do I get this to work ? Here is a snippet of the code I have for the adapter : -

$adapter = new Zend\Http\Client\Adapter\Socket();
$adapter->setStreamContext(array(
'ssl' => array(
    'verify_peer' => true,
    'allow_self_signed' => false,
    'cafile' => '/usr/local/psa/var/certificates/ca-bundle.pem',
    'verify_depth' => 5,
    'CN_match' => 'https://www.mydomain.co.uk'
)
));

$client->setAdapter($adapter);

谢谢,

推荐答案

我在尝试安装 Composer 时遇到了同样的错误.以下命令为我纠正了问题.

I received the same error when trying to install Composer. The following command corrected the problem for me.

sudo update-ca-certificates

我按照给定的说明在此服务器上安装了 SSL 证书,它适用于 https 连接.只有在尝试安装 Composer 时,我才看到无法设置验证位置"错误.我希望这可以为其他人节省我花费的研究时间!

I had installed an SSL certificate on this server following given instructions and it worked for the https connection. It was only when trying to install Composer that I saw the "unable to set verify locations" error. I hope this can save others the hours of research time it cost me!

这篇关于为什么 Zend 2 http 不验证我的 ssl 证书?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-18 22:26