IRC bot - allow to disable ssl check

In PHP 5.6.x stream wrappers verify peer certificates and host names by default when using SSL. That fix allows to turn off that verification with config option $config['irc_disable_ssl_check'] = true; 
It is useful when you want to use self generated certificate for your own IRC server.
This commit is contained in:
deutor
2016-08-25 13:58:32 +02:00
committed by GitHub
parent ec12273aa7
commit c72b39cbf4

10
irc.php
View File

@ -375,7 +375,15 @@ class ircbot {
$server = $this->server;
}
$this->socket['irc'] = fsockopen($server, $this->port);
if ($this->ssl && $this->config['irc_disable_ssl_check']) {
$ssl_context_params = array('ssl'=>array('allow_self_signed'=> true, 'verify_peer' => false, 'verify_peer_name' => false ));
$ssl_context = stream_context_create($context_params);
$this->socket['irc'] = stream_socket_client($server.':'.$this->port, $errno, $errstr, 30, STREAM_CLIENT_CONNECT, $ssl_context);
}
else {
$this->socket['irc'] = fsockopen($server, $this->port);
}
if (!is_resource($this->socket['irc'])) {
return $this->connect($try + 1);
}