doushi3803 2017-05-08 13:38
浏览 621

PHP stream_socket_client():无法连接到https

I've just noticed the new vulnerability discovered in Wordpress and I'm trying to fix it with the following code (but with any success

<?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
Content-Type: application/x-www-form-urlencoded
Content-Length: ". strlen($data) ."
",
        '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);
?>

The error log I got is just like this:

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

Where mywebip represents the actual ip that hosts my website and website and mailserver the DNS directions of the services.

Thank you.

  • 写回答

1条回答 默认 最新

  • dongyan8896 2017-05-08 13:51
    关注

    Via socket you do not specify a protocol.

    http://php.net/stream_socket_client

    First parameter:

    remote_socket

    Address to the socket to connect to.

    Adress is only mywebip.

    You should use CURL instead.

    See http://php.net/manual/en/curl.examples.php

    The other problem (with fopen(), which can handle streams with protocols!) is a malformed/wrong certificate issued by your webserver.

    Use this service to debug problems with your webservers certificate:

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

    评论

报告相同问题?

悬赏问题

  • ¥15 c程序不知道为什么得不到结果
  • ¥40 复杂的限制性的商函数处理
  • ¥15 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置