php 无法找到套接字传输“https”

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/378574/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-24 22:32:34  来源:igfitidea点击:

Unable to find the socket transport "https"

phpiisfsockopen

提问by Chris J Allen

I'm using this to check for the availability of a URL:

我正在使用它来检查 URL 的可用性:

$fp = fsockopen($url, 443, $errno, $errstr);

and I get this error back...

我又得到了这个错误......

Warning: fsockopen() [function.fsockopen]: unable to connect to https://example.com/soapserver.php:443(Unable to find the socket transport "https" - did you forget to enable it when you configured PHP?) in C:\Home etc etc....

警告:fsockopen() [function.fsockopen]:无法连接到https://example.com/soapserver.php:443(无法找到套接字传输“https”-您是否在配置 PHP 时忘记启用它? ) 在 C:\Home 等....

I'm using an IIS server btw,( no its not my doing! ) so I think its something to do with not having open-ssl, but I'm not sure. Can anyone help please?

顺便说一句,我正在使用 IIS 服务器,(不,这不是我做的!)所以我认为这与没有 open-ssl 有关系,但我不确定。有人可以帮忙吗?

I did a phpinfo() and I do have ssl, but on IMAP and cURL, thats all.

我做了一个 phpinfo() 并且我有 ssl,但是在 IMAP 和 cURL 上,仅此而已。

Any ideas?

有任何想法吗?

采纳答案by Martijn Laarman

also for ssl you need to prefix the host with ssl://

同样对于 ssl,您需要在主机前加上 ssl://

回答by Sérgio

Uncomment the line: extension=php_openssl.dllin php.ini

取消注释该行:extension=php_openssl.dllphp.ini

回答by tvanfosson

You should be using just the hostname, not the URL in the fsockopen call. You'll need to provide the uri, minus the host/port in the actual HTTP headers. As @Martijin noted, and as listed in the manual page, you'll need to preface your host name with ssl:// for SSL or tls:// if using transport layer security.

您应该只使用主机名,而不是 fsockopen 调用中的 URL。您需要提供 uri,减去实际 HTTP 标头中的主机/端口。正如@Martijin 指出的那样,并且如手册页中所列,如果使用传输层安全性,您需要在主机名前加上 ssl:// 以表示 SSL 或 tls://。

Manual pagefor fsockopen. Look at Example #1.

fsockopen 的手册页。看示例#1。

回答by Nino ?kopac

Let's say you wanted to grab NY Times, which enforces HTTPS:

假设您想获取强制执行 HTTPS 的纽约时报:

Incorrect:

不正确:

$client = stream_socket_client('https://www.nytimes.com', $errno, $errstr, 30);

$client = stream_socket_client('https://www.nytimes.com', $errno, $errstr, 30);

Correct:

正确的:

$client = stream_socket_client('tcp://www.nytimes.com:443', $errno, $errstr, 30);

$client = stream_socket_client('tcp://www.nytimes.com:443', $errno, $errstr, 30);

Note I've replaced https://with tcp://and appended the 443 port to the hostname.

注意我把它换成https://tcp://和追加的443端口的主机名。

I guess we can say that stream_socket_client()does not speak URLs.

我想我们可以说不stream_socket_client()说 URL。

回答by Tony Schmidt

Switching to ssl://worked for me but I kept getting a BAD REQUEST response. I found that I needed to add one more line to declare explicitly my Host Header as described hereand ensure that I've updated my HTTP from HTTP/1.0to HTTP/1.1:

切换到ssl://为我工作,但我一直收到 BAD REQUEST 响应。我发现我需要再添加一行来明确声明我的主机头,如here所述并确保我已将我的 HTTP 更新HTTP/1.0HTTP/1.1

$header .= "POST /cgi-bin/webscr HTTP/1.1\r\n";
$header .= "Host: www.sandbox.paypal.com\r\n";

回答by S.Abbu

Check curl installed or not for php. if it is not installed install the curl. for windows Uncomment the line: extension=php_openssl.dll in php.ini, for ubuntu sudo apt-get install php-curl

检查 php 是否安装了 curl。如果未安装,请安装 curl。对于 windows 取消注释行:extension=php_openssl.dll in php.ini,对于 ubuntu sudo apt-get install php-curl