walkor / phpsocket.io

A server side alternative implementation of socket.io in PHP based on workerman.
2.3k stars 508 forks source link

SSL handshake error: stream_socket_enable_crypto(): SSL operation failed with code 1. OpenSSL Error messages: error:0A00009C:SSL routines::http request #286

Open binemmanuel opened 1 year ago

binemmanuel commented 1 year ago

I need to be able to access the server without SSL, when I try I get the SSL handshake error;

SSL handshake error: stream_socket_enable_crypto(): SSL operation failed with code 1. OpenSSL Error messages: error:0A00009C:SSL routines::http request

It was working fine previously or maybe I'm missing what I did to make it work fine previous before the server was destroyed and now recreating even with the proxy isn't working fine.

domain.com-le-ssl.conf

RewriteEngine on
RewriteCond %{REQUEST_URI}  ^/socket.io            [NC]
RewriteCond %{QUERY_STRING} transport=websocket    [NC]
RewriteCond %{HTTP:Upgrade} websocket              [NC]
RewriteCond %{HTTP:Connection} upgrade             [NC]
RewriteRule /(.*)           ws://domain.com:8181/$1 [P,L]

ProxyRequests Off
ProxyPass "/socket.io/" "http://domain.com:8181/socket.io/"
ProxyPassReverse "/socket.io/" "http://domain.com:8181/socket.io/"

server.php

$context = [
    'ssl' => [
        'local_cert'  => '/etc/letsencrypt/live/domain.come/fullchain.pem',
        'local_pk'    => '/etc/letsencrypt/live/domain.com/privkey.pem',
        'allow_self_signed' => true,
        'verify_peer' => false,
        'verify_peer_name' => false,
    ]
];

$io = new SocketIO(8181, $context);

if I don't pass the "$context" when initialising SocketIO object, then the client app can connect successfully, but I wish it could be over SSL.