【发布时间】:2016-09-10 00:33:45
【问题描述】:
我正在编写一个多线程 php 客户端,它向 apache 反向代理发出 https 请求并测量一些统计数据。我正在写一篇关于通过 TLS 会话恢复提高性能的学士论文。现在我需要做一个概念证明来证明/反驳这一点。目前我有这个代码:
$this->synchronized(function($this){
$this->before = microtime(true);
}, $this);
$url = 'https://192.168.0.171/';
# Some dummy data
$data = array('name' => 'Nicolas', 'bank account' => '123462343');
// use key 'http' even if you send the request to https://...
$options = array(
'http' => array(
'header' => "Content-type: application/x-www-form-urlencoded\r\n",
'method' => 'POST',
'content' => http_build_query($data)
),
"ssl" => array(
"verify_peer" => false,
"verify_peer_name" => false,
"ciphers" => "HIGH:!SSLv2:!SSLv3"
)
);
$context = stream_context_create($options);
$result = file_get_contents($url, false, $context);
$this->synchronized(function($this){
$this->after = microtime(true);
}, $this);
$this->counter_group->write($this->before, $this->after, $result);
这段代码可以进行完整的握手,但我似乎无法弄清楚如何在 php 中进行恢复握手?
任何帮助将不胜感激!
【问题讨论】:
-
... 或反驳。 :)
-
file_get_contents() 在请求后立即关闭 TCP 连接……通常。需要保持活动连接头和带有句柄的 fopen()……遗憾的是,我现在没有足够的时间进行调查:-/
标签: php session ssl resume reconnect