我正在尝试设置我们的内部 Satis 服务器,它应该可以通过 HTTPS 访问(证书由内部 CA 签名)。 在 Linux 上,一旦将 CA 的根证书添加到证书存储(例如/etc/ssl/certs/ca-certificates.crt),一切都会按预期进行。 但是在我的 Mac 上,即使在将证书添加到 OS X Keychain 后,我仍收到“SSL 操作失败,代码 1”错误。 在命令行上 curl 并在 PHP 中使用 libcurl 可以获取 HTTPS URL,但 Composer 和 file_get_contents(由 Composer 使用)总是抛出“SSL 操作失败,代码 1”错误。
我知道我可以在我的 php.ini 中指定“openssl.capath”,但为什么它在不指定路径的情况下与 Curl 一起工作?
最佳答案
我终于想通了:
Curl 使用 SecureTransport 而不是 OpenSSL,因此它直接使用 OS X Keychain,因此可以使用由公共(public) CA 和我们的内部 CA 签名的证书(我之前已将其添加到系统钥匙串(keychain))。
file_get_contents 使用 OpenSSL,OpenSSL 使用它自己的位于 /usr/local/etc/openssl/cert.pem
的 CA 包。
由于默认情况下/usr/local/etc/openssl/cert.pem 仅包含公共(public) CA,我必须将证书从我的钥匙串(keychain)(系统和系统根)导出到 OpenSSL 的 cert.pem:security查找证书-a -p/Library/Keychains/System.keychain/System/Library/Keychains/SystemRootCertificates.keychain | sudo tee/usr/local/etc/openssl/cert.pem
现在 file_get_contents()
适用于内部和外部证书/CA。
但是 Composer 没有查看 /usr/local/etc/openssl/cert.pem
,所以我不得不将 openssl.cafile php.ini 属性设置为 的路径证书.pem
:
[openssl]
openssl.cafile =/usr/local/etc/openssl/cert.pem
关于php - 将 Satis 与 HTTPS(内部 CA)结合使用时,Composer 失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38379651/