【问题标题】:PHP stream_socket_client not working in chrooted environmentPHP stream_socket_client 在 chrooted 环境中不起作用
【发布时间】:2018-06-22 12:35:54
【问题描述】:

我尝试使用 stream_socket_client() 打开一个 ssh 连接,但得到:

Could not open socket: stream_socket_client(): SSL operation failed with code 1. OpenSSL Error messages:
error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed
2018-06-22T13:07:35+02:00 EMERG (0): #0 [internal function]: Zend\Mail\Protocol\AbstractProtocol->Zend\Mail\Protocol\{closure}(2, 'stream_socket_c...', '/httpdocs/vendo...', 213, Array)
#1 /httpdocs/vendor/zendframework/zend-mail/src/Protocol/AbstractProtocol.php(213): stream_socket_client('ssl://lotsearch...', 0, '', 30)
#2 /httpdocs/vendor/zendframework/zend-mail/src/Protocol/Smtp.php(185): Zend\Mail\Protocol\AbstractProtocol->_connect('ssl://lotsearch...')
#3 /httpdocs/vendor/zendframework/zend-mail/src/Transport/Smtp.php(397): Zend\Mail\Protocol\Smtp->connect()
#4 /httpdocs/vendor/zendframework/zend-mail/src/Transport/Smtp.php(383): Zend\Mail\Transport\Smtp->connect()
#5 /httpdocs/vendor/zendframework/zend-mail/src/Transport/Smtp.php(394): Zend\Mail\Transport\Smtp->lazyLoadConnection()
#6 /httpdocs/vendor/zendframework/zend-mail/src/Transport/Smtp.php(251): Zend\Mail\Transport\Smtp->connect()

我在 chrooted 环境中执行此命令。如果我使用“普通”bash 作为 shell,一切正常。 起初我认为 chrooted 用户需要访问 openssh 二进制文件。 但即使可以访问它,它也不起作用。

顺便说一句,wget https://google.com 也不起作用。

任何想法如何让 ssl 证书验证在 chrooted 环境中工作?

【问题讨论】:

    标签: php ssl-certificate chroot stream-socket-client


    【解决方案1】:

    好的,我想通了:

    您需要在 chrooted 环境中提供以下内容:

    /usr/bin/openssl
    /usr/lib/ssl
    /etc/ssl
    /usr/share/ca-certificates
    

    那么 PHP 的 stream_socket_client() 函数就可以对证书进行 SSL 验证了。 Wget 现在也适用于受 SSL 保护的网站 wget https://google.com

    【讨论】:

    • 由于我自己遇到了 SSL 问题,我想补充一点,我缺少 /usr/local/share/ca-certificates 用于我们在机器上部署的我们自己的 CA!跨度>
    • 您能否让答案更具体 - 您所说的“可用”是指可读吗?可写?属于用户组?抱歉,如果这有点偏离轨道,我真的不了解 chroot
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-01-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多