gpt4 book ai didi

PHP stream_socket_client() : unable to connect to https

转载 作者:太空宇宙 更新时间:2023-11-03 14:40:18 26 4
gpt4 key购买 nike

我刚刚注意到在 Wordpress 中发现的新漏洞,我正在尝试使用以下代码修复它(但都成功了

<?php

$url = 'https://mywebip/wp-login.php?action=lostpassword';
$data = 'user_login=admin&redirect_to=&wp-submit=Get+New+Password';

// use key 'http' even if you send the request to https://...
$options = array(
'http' => array(
'header' => "Host: mailserver\r\nContent-Type: application/x-www-form-urlencoded\r\nContent-Length: ". strlen($data) ."\r\n",
'method' => 'POST',
'content' => $data,
'ssl'=>array('verify_peer'=>true, 'capath'=>'/etc/ssl/certs')
)
);
$context = stream_context_create($options);
//$result = file_get_contents($url, false, $context);

$fp = stream_socket_client($url, $errno, $errstr, 30);
//stream_socket_enable_crypto($fp, true, STREAM_CRYPTO_METHOD_SSLv23_CLIENT);

$fp = fopen($url, 'r', false, $context);

if ($fp === FALSE) { /* Handle error */ }

var_dump($result);
?>

我得到的错误日志是这样的:

PHP Warning:  stream_socket_client(): unable to connect to https://mywebip/wp-login.php?action=lostpassword (Unable to find the socket transport "https" - did you forget to enable it when you configured PHP?) in /home/jorge/Escritorio/joomla.php on line 18

PHP Warning: fopen(): Peer certificate CN=`website` did not match expected CN=`mywebip' in /home/jorge/Escritorio/joomla.php on line 21

PHP Warning: fopen(): Failed to enable crypto in /home/jorge/Escritorio/joomla.php on line 21

PHP Warning: fopen(https://mywebip/wp-login.php?action=lostpassword): failed to open stream: operation failed in /home/jorge/Escritorio/joomla.php on line 21

mywebip 代表托管我网站的实际 ip,websitemailserver 代表服务的 DNS 方向。

谢谢。

最佳答案

通过套接字,您无需指定协议(protocol)。

http://php.net/stream_socket_client

第一个参数:

remote_socket

Address to the socket to connect to.

地址只是mywebip

您应该改用 CURL。

参见 http://php.net/manual/en/curl.examples.php

另一个问题(fopen(),它可以处理带有协议(protocol)的流!)是您的网络服务器颁发的格式错误/错误的证书。

使用此服务来调试您的网络服务器证书的问题:

https://www.ssllabs.com/ssltest/

关于PHP stream_socket_client() : unable to connect to https,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43849206/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com