V
V
vladymyr_olegovich2014-09-03 12:58:00
PHP
vladymyr_olegovich, 2014-09-03 12:58:00

How to set up WebSocket on a self-written SSL certificate (HTTPS)?

I've been dealing with this problem for a week now! Very urgent!
Everything works fine on http, but when I switch to https, it does not connect to the socket server.
The certificate is self-written, created in ispmanager.
Connection code:

var socket = new WebSocket("wss://ixbh.com:8888/server.php");


Socket server code:
$context = stream_context_create();
stream_context_set_option($context, 'ssl', 'local_cert', 'ssl.crt/server.pem');
stream_context_set_option($context, 'ssl', 'allow_self_signed', true);
stream_context_set_option($context, 'ssl', 'verify_peer', false);
$socket = stream_socket_server("ssl://0.0.0.0:8888", $errno, $errstr, STREAM_SERVER_BIND|STREAM_SERVER_LISTEN, $context);
while(true){
....
    if (in_array($socket, $read)) {
        //При попытке соединится, код доходит сюда
        if (($connect = stream_socket_accept($socket, -1)) && $info = handshake($connect)) {
            //сюда код уже не доходит
            $connects[] = $connect;
        }
        unset($read[array_search($socket, $read)]);
    }
....
}

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Andrey Burov, 2014-09-03
@BuriK666

habrahabr.ru/post/235435

V
Viktor, 2014-12-17
@Levhav

valera.ws/2012.03.11~free-valid-signed-ssl-certifi...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question