Debian 6 下的 XAMPP:无法打开“ssl://”网址

发布于 2024-11-30 11:38:06 字数 1223 浏览 1 评论 0原文

我在使用 ssl:// 方案打开 URL 时遇到问题。详细说明:

phpinfo(): http://pastie.org/2391404

示例代码:

$socket = @fsockopen("ssl://cgw.ubb.bg", 443, $errno, $errstr, 30);
if (!$socket) {
  $err = "$errstr ($errno) - " . $socket;
  echo "Unable to connect. $err";
} else {
  echo "Connected.";
  fclose($socket);
}

echo PHP_EOL;

我得到的回复是:

无法连接。 (0) -

(是的,我确实尝试使用 telnet/浏览器/等连接,主机/端口组合不是问题。)

换句话说,errno 是 0,并且没有提供错误消息。

当我将其放入 /opt/lampp/etc/php.ini 中时:

extension="openssl.so"

我收到此错误:

警告:PHP 启动:无法加载动态库 '/opt/lampp/lib/ php/extensions/no-debug-non-zts-20090626/openssl.so' - /opt/lampp/lib/php/extensions/no-debug-non-zts-20090626/openssl.so: 无法打开共享对象文件: 在 Unknown on line 0 中没有这样的文件或目录

唉,确实有那里没有 openssl.so 文件。

我的 XAMPP 平台是:i686-pc-linux-gnu

我的问题是:

我可以通过下载正确的文件并完成它来以某种方式“作弊”吗? 如果没有,我如何从源代码编译它并将其集成到 XAMPP 中而不将其分解?

编辑: 遗憾的是,到目前为止还没有给出可行的建议。考虑到我使用了现成的 XAMPP 安装(基本上解压了存档)并且 XAMPP 的使用相当广泛,我很惊讶没有其他人偶然发现这个问题。

I am having trouble opening URLs with the ssl:// scheme. Detailing:

phpinfo(): http://pastie.org/2391404

Sample code:

$socket = @fsockopen("ssl://cgw.ubb.bg", 443, $errno, $errstr, 30);
if (!$socket) {
  $err = "$errstr ($errno) - " . $socket;
  echo "Unable to connect. $err";
} else {
  echo "Connected.";
  fclose($socket);
}

echo PHP_EOL;

What I get in response is this:

Unable to connect. (0) -

(Yes, I did try to connect with telnet/browser/etc., the host/port combo is not the problem.)

In other words, errno is 0, and no error message is provided.

When I put this in /opt/lampp/etc/php.ini:

extension="openssl.so"

I am getting this error:

Warning: PHP Startup: Unable to load dynamic library '/opt/lampp/lib/php/extensions/no-debug-non-zts-20090626/openssl.so' - /opt/lampp/lib/php/extensions/no-debug-non-zts-20090626/openssl.so: cannot open shared object file: No such file or directory in Unknown on line 0

Alas, there is indeed no openssl.so file in there.

My XAMPP platform is: i686-pc-linux-gnu.

My question is:

Can I "cheat" somehow by just downloading the proper file and be done with it?
If not, how could I compile it from source and integrate it into XAMPP without ripping it apart?

EDIT:
It's a shame no viable suggestions were given thus far. Having in mind I used a ready-made XAMPP installation (basically unpacked the archive) and that XAMPP is pretty broadly used, I am very surprised nobody else stumbled upon this problem.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

横笛休吹塞上声 2024-12-07 11:38:06

在花了几个小时在 debian 上调试这个问题(安装了 libssl0.9.8 的挤压)后,我找到了解决方案。
我正在使用 dotdeb.org php 版本:php5-cgi 5.3.13-1~dotdeb.0(似乎不适用于 debian 默认包 5.3.3-7+squeeze13! - 此版本中仍然缺少 no_ticket )。

解决方案是像这样打开套接字:

<?php
 $host = "ssl://cgw.ubb.bg";
 $context = stream_context_create(); 
 $result = stream_context_set_option($context, 'ssl', 'no_ticket',true);
 $socket = stream_socket_client($host.':443', $errno, $errstr, 30, STREAM_CLIENT_CONNECT, $context);

之后您只需使用套接字,因为它是 fsockopen 资源。

After losing few hours to debug this problem on debian (squeeze with libssl0.9.8 installed) I've found a solution.
I'm using a dotdeb.org php version: php5-cgi 5.3.13-1~dotdeb.0 (doesn't seems to work with debian default package 5.3.3-7+squeeze13! - no_ticket is still missing in this version).

The solutions is to open the socket like this:

<?php
 $host = "ssl://cgw.ubb.bg";
 $context = stream_context_create(); 
 $result = stream_context_set_option($context, 'ssl', 'no_ticket',true);
 $socket = stream_socket_client($host.':443', $errno, $errstr, 30, STREAM_CLIENT_CONNECT, $context);

afterwards you simply use the socket as it was a fsockopen resource.

长安忆 2024-12-07 11:38:06

从您的 phpinfo() 中,可以使用 openssl :

openssl

OpenSSL support => enabled
OpenSSL Library Version => OpenSSL 1.0.0c 2 Dec 2010
OpenSSL Header Version => OpenSSL 1.0.0c 2 Dec 2010

PHP 允许将 openssl 构建到核心中,在这种情况下,它不需要位于单独的扩展中。 file_get_contents("https://cgw.ubb.bg/") 是否会给您同样的错误?

编辑:这似乎是 openssl 中的一个错误:我尝试了我提供的示例,并收到以下错误:

error:140773F2:SSL routines:SSL23_GET_SERVER_HELLO:sslv3 alert unexpected message 

在谷歌搜索后,我发现多个错误报告/论坛帖子似乎都说这是 openssl lib 和远程服务器。显然,强制 openssl 到 sslv3 可以纠正问题,但我不知道如何使用 php 来做到这一点。

一些错误报告(与 php 无关):

https://bugs.launchpad .net/ubuntu/+source/curl/+bug/595415

http://forum.parallels.com/printthread.php?t=82502

From your phpinfo(), openssl is available :

openssl

OpenSSL support => enabled
OpenSSL Library Version => OpenSSL 1.0.0c 2 Dec 2010
OpenSSL Header Version => OpenSSL 1.0.0c 2 Dec 2010

PHP allows building openssl into the core, and in that case it does not need to be in a separate extension. Does a file_get_contents("https://cgw.ubb.bg/") gives you the same error ?

EDIT : This seems to be a bug in openssl : I tried the sample I provided, and got the following error :

error:140773F2:SSL routines:SSL23_GET_SERVER_HELLO:sslv3 alert unexpected message 

After googling it, I found multiple bug reports / forum posts that all seem to say it is a problem between the openssl lib and the remote server. Apparently, forcing openssl to sslv3 corrects the problem, but I don't know how to do this with php.

Some bug reports (not related to php) :

https://bugs.launchpad.net/ubuntu/+source/curl/+bug/595415

http://forum.parallels.com/printthread.php?t=82502

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文