无法让 Guzzle 接受证书
Can't make Guzzle accept a certificate
我试图让服务器 A 通过 HTTPS 请求与服务器 B 通信。服务器 B 有我的雇主颁发给我的证书,通过 Safari 和 Chrome 连接到它没有任何问题。
但是,当尝试通过 Guzzle 从 A 向 B 发送请求时,出现以下错误:
GuzzleHttp/Exception/RequestException with message 'cURL error 60: SSL certificate problem:
unable to get local issuer certificate (see https://curl.haxx.se/libcurl/c/libcurl-errors.html)'
我试过将证书文件设置为参数 ([verify => '/path/to/cert.pem']
),但是,首先,我只有 .crt
、.csr
和 .key
文件;我尝试通过在其他地方找到的这些说明制作 .pem
文件:
(optional) Remove the password from the Private Key by following the steps listed below:
openssl rsa -in server.key -out nopassword.key
Note: Enter the pass phrase of the Private Key.
Combine the private key, public certificate and any 3rd party intermediate certificate files:
cat nopassword.key > server.pem
cat server.crt >> server.pem
Note: Repeat this step as needed for third-party certificate chain files, bundles, etc:
cat intermediate.crt >> server.pem
这没有用——错误是一样的。该请求在 'verify' 设置为 false 的情况下工作,但这显然不是生产选项。
证书不是我通常使用的东西,所以我很难弄清楚问题可能出在哪里,更不用说修复它了。任何帮助将不胜感激。
编辑
我也尝试了 Guzzle Curl Error 60 SSL unable to get local issuer 中建议的解决方案,但无济于事。
发生这种情况是因为我在服务器 B 上配置的唯一证书是最终用户证书。
我是新手,所以我的解释可能有缺陷,但根据我的理解,最终用户证书 link 回到受信任的证书颁发机构 (CA) 证书,具有零个或多个中间证书 in-between。浏览器可以找出这个证书链,并下载缺少的所需证书; cURL 没有。
因此,解决方案是使用缺少的证书配置服务器 B。如何做到这一点是一个完全不同的问题,所以我不会在这个答案中讨论它。
我试图让服务器 A 通过 HTTPS 请求与服务器 B 通信。服务器 B 有我的雇主颁发给我的证书,通过 Safari 和 Chrome 连接到它没有任何问题。
但是,当尝试通过 Guzzle 从 A 向 B 发送请求时,出现以下错误:
GuzzleHttp/Exception/RequestException with message 'cURL error 60: SSL certificate problem:
unable to get local issuer certificate (see https://curl.haxx.se/libcurl/c/libcurl-errors.html)'
我试过将证书文件设置为参数 ([verify => '/path/to/cert.pem']
),但是,首先,我只有 .crt
、.csr
和 .key
文件;我尝试通过在其他地方找到的这些说明制作 .pem
文件:
(optional) Remove the password from the Private Key by following the steps listed below:
openssl rsa -in server.key -out nopassword.key
Note: Enter the pass phrase of the Private Key.
Combine the private key, public certificate and any 3rd party intermediate certificate files:
cat nopassword.key > server.pem
cat server.crt >> server.pem
Note: Repeat this step as needed for third-party certificate chain files, bundles, etc:
cat intermediate.crt >> server.pem
这没有用——错误是一样的。该请求在 'verify' 设置为 false 的情况下工作,但这显然不是生产选项。
证书不是我通常使用的东西,所以我很难弄清楚问题可能出在哪里,更不用说修复它了。任何帮助将不胜感激。
编辑 我也尝试了 Guzzle Curl Error 60 SSL unable to get local issuer 中建议的解决方案,但无济于事。
发生这种情况是因为我在服务器 B 上配置的唯一证书是最终用户证书。
我是新手,所以我的解释可能有缺陷,但根据我的理解,最终用户证书 link 回到受信任的证书颁发机构 (CA) 证书,具有零个或多个中间证书 in-between。浏览器可以找出这个证书链,并下载缺少的所需证书; cURL 没有。
因此,解决方案是使用缺少的证书配置服务器 B。如何做到这一点是一个完全不同的问题,所以我不会在这个答案中讨论它。