【问题标题】:PHP - Unable to find the socket transport "ssl"PHP - 找不到套接字传输“ssl”
【发布时间】:2020-02-11 15:30:48
【问题描述】:

系统信息

  • Win 10 Pro x64
  • PHP 7.3.10 x64 TS
  • HTTPD 2.4.34

我已按照本指南生成必要的密钥和证书文件。

How do I allow HTTPS for Apache on localhost?

httpd.conf

LoadModule ssl_module modules/mod_ssl.so

额外/vhosts.conf

<IfModule ssl_module>
    <VirtualHost _default_:443>
        SSLEngine on
        SSLCertificateFile "${CONF_PATH}/certs/localhost.cert"
        SSLCertificateKeyFile "${CONF_PATH}/certs/localhost.key"

        ...
    </VirtualHost>
</IfModule>

php.ini

extension=openssl

[curl]
curl.cainfo="C:\bin\httpd\conf\certs\localhost.cert"

[openssl]
openssl.cafile="C:\bin\httpd\conf\certs\localhost.cert"

这通常是人们会说复制libeay32ssleay32 的地方,但只是为了向其他人记录这一点,这些不再是最新版本中包含的文件。他们现在是libcryptolibssh。我将它们复制到 Apache bin 目录中。

转到带有phpinfo() 的页面会确认这些设置,并将 SSL 标记为启用。

让我们做一些 HTTPS 请求。

pecl update-channels
Updating channel "doc.php.net"
Channel "doc.php.net" is up to date
Updating channel "pear.php.net"
Channel "pear.php.net" is not responding over http://, failed with message: Connection to `ssl://pear.php.net:443' failed: Unable to find the socket transport "ssl" - did you forget to enable it when you configured PHP?
Trying channel "pear.php.net" over https:// instead
Cannot retrieve channel.xml for channel "pear.php.net" (Connection to `ssl://pear.php.net:443' failed: Unable to find the socket transport "ssl" - did you forget to enable it when you configured PHP?)
Updating channel "pecl.php.net"
Channel "pecl.php.net" is up to date

好吧,那不好。我看到了一些关于从 PECL 脚本中删除 -n 标志的建议。所以我就这么做了。让我们看看现在有什么不同。

pecl update-channels
Updating channel "doc.php.net"
Channel "doc.php.net" is up to date
Updating channel "pear.php.net"
Channel "pear.php.net" is not responding over http://, failed with message: Connection to `ssl://pear.php.net:443' failed:
Trying channel "pear.php.net" over https:// instead
Cannot retrieve channel.xml for channel "pear.php.net" (Connection to `ssl://pear.php.net:443' failed: )
Updating channel "pecl.php.net"
Channel "pecl.php.net" is up to date

不,实际上更糟。现在关于它为什么失败的细节更少了。

有人对我为什么没有成功有任何额外的见解吗?

【问题讨论】:

  • 您是否在php.ini 中启用了php_openssl
  • 应该有像extension=php_openssl.dll 这样的行,您可以取消注释并使用。如果没有,只需添加该行并重新启动服务器以查看它是否有效。
  • 请检查this answerthis answer
  • 是的,它已启用。我已经说过了。我提出这个问题是因为这是任何人唯一的答案,但它不起作用。

标签: php ssl pear


【解决方案1】:

您的 HTTPD php.ini(您已使用“Going to a page with phpinfo()”检查)可能与您的 pecl(命令行)php.ini 文件不同。确保pecl 使用的是启用了 openssl 的 php.ini。见pecl config-show,也见https://stackoverflow.com/a/49623714/68939

【讨论】:

  • 没有设置,所以我用pecl config-set php_ini "C:\bin\php\%PHP_VERSION%\php.ini"手动设置了,结果还是一样。
  • @DissidentRage,我和你的处境完全一样。击中完全相同的墙壁。我快要放弃了。
【解决方案2】:

我设法通过编辑 pecl.bat 让它工作。在它有这个之前:

"%PHP_PEAR_PHP_BIN%" -C -n -d date.timezone=UTC -d output_buffering=1 -d safe_mode=0 -d "include_path='%PHP_PEAR_INSTALL_DIR%'" -d register_argc_argv="On" -d variables_order=EGPCS -f "%PHP_PEAR_INSTALL_DIR%\peclcmd.php" -- %1 %2 %3 %4 %5 %6 %7 %8 %9

我改成:

"%PHP_PEAR_PHP_BIN%" -c "%PHP_PEAR_BIN_DIR%\php.ini" -C -n -d date.timezone=UTC -d output_buffering=1 -d safe_mode=0 -d "include_path='%PHP_PEAR_INSTALL_DIR%'" -d register_argc_argv="On" -d variables_order=EGPCS -f "%PHP_PEAR_INSTALL_DIR%\peclcmd.php" -- %1 %2 %3 %4 %5 %6 %7 %8 %9

也就是说,我添加了这部分:

-c "%PHP_PEAR_BIN_DIR%\php.ini"

这与here 给出的建议相同。

更新

在这之后我得到了一个新的错误:

Fatal error: Cannot use result of built-in function in write context in C:\xampp\php\pear\Archive\Tar.php on line 639

所以我去编辑了 Tar.php 并更改了这个:

$v_att_list = & func_get_args();

到这里:

$v_att_list = func_get_args();

似乎让我更进一步,但现在我明白了:

ERROR: The DSP mailparse.dsp does not exist.

搜索继续......

【讨论】:

  • 只需添加此-c "%PHP_PEAR_BIN_DIR%\php.ini" 行对我有用!谢谢你!
猜你喜欢
  • 2013-05-14
  • 1970-01-01
  • 1970-01-01
  • 2017-06-23
  • 2012-04-15
  • 1970-01-01
  • 2010-12-14
  • 2013-06-19
  • 2014-03-24
相关资源
最近更新 更多