下面的代码来自Elephant.io client.php握手方法。
$ch = curl_init($this->socketIOUrl);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
if (!$this->checkSslPeer)
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
if (!is_null($this->handshakeTimeout)) {
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT_MS, $this->handshakeTimeout);
curl_setopt($ch, CURLOPT_TIMEOUT_MS, $this->handshakeTimeout);
}
if ($this->origin) {
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
$this->getOrigin()
));
}
if ($this->sendCookie && $this->cookie) {
curl_setopt($ch, CURLOPT_COOKIE, $this->cookie);
}
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true); // from here below 4 lines seems problem
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
curl_setopt($ch, CURLOPT_CAINFO, "/etc/ssl/certs/cacert.pem");
curl_setopt($ch, CURLOPT_CAPATH, "/etc/ssl/certs/");
$res = curl_exec($ch);
if ($res === false || $res === '') {
throw new \Exception(curl_error($ch)); // here throws exception
}
此代码抛出异常。 SSL证书问题:无法获得本地颁发者证书。
我尝试过命令 openssl s_client -showcerts -CApath / etc / ssl / certs -connect amallu.com:443-servername amallu.com 它返回ok。
请帮忙解决