Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can I run chat on https server? #12

Closed
MaksimDzhangirov opened this issue May 17, 2017 · 6 comments
Closed

Can I run chat on https server? #12

MaksimDzhangirov opened this issue May 17, 2017 · 6 comments
Labels

Comments

@MaksimDzhangirov
Copy link

MaksimDzhangirov commented May 17, 2017

I changed this part in index.html:
ws = new WebSocket("wss://"+document.domain+":7272");
and enable ssl in start_gateway.php

$context = array(
    'ssl' => array(
        'local_cert' => __DIR__ . '/path',
        'local_pk'   => __DIR__ . '/path'        
    )
);

// gateway process
$gateway = new Gateway("Websocket://0.0.0.0:7272", $context);
$gateway->transport = 'ssl';

Get following error:
Warning: stream_socket_enable_crypto(): SSL operation failed with code 1. OpenSSL Error messages:
error:14094418:SSL routines:SSL3_READ_BYTES:tlsv1 alert unknown ca in /home/orgjvpwd/public_html/user_account/video-server/vendor/workerman/workerman/Connection/TcpConnection.php on line 391

SSL Handshake fail.

@walkor
Copy link
Owner

walkor commented May 17, 2017

Please upgrade workerman to the latest version.
Try to add 'verify_peer' => false to $context like this.

$context = array(
    'ssl' => array(
        'local_cert'     => __DIR__ . '/path',
        'local_pk'       => __DIR__ . '/path',
        'verify_peer'  => false,   
    )
);

The Buffer information is displayed when an error occurs like this.

Warning: stream_socket_enable_crypto(): SSL operation failed with code 1. OpenSSL Error messages:
error:1408F10B:SSL routines:SSL3_GET_RECORD:wrong version number in /home/www/workerman-chat/vendor/workerman/workerman/Connection/TcpConnection.php on line 392

SSL Handshake fail. 
Buffer:20485454502f312e310d0a486f73743a206c6179636861742e776f726b65726d616e2e6e...

Please show the Buffer information.

@MaksimDzhangirov
Copy link
Author

Adding
'verify_peer' => false,
didn't help.

My Workerman version:
----------------------- WORKERMAN -----------------------------
Workerman version:3.4.2 PHP version:7.1.5
------------------------ WORKERS -------------------------------
worker listen processes status
ChatBusinessWorker none 1 [OK]
ChatGateway websocket://0.0.0.0:7272 1 [OK]
Register text://0.0.0.0:1236 1 [OK]
WebServer http://0.0.0.0:55151 2 [OK]

Warning: stream_socket_enable_crypto(): SSL operation failed with code 1. OpenSSL Error messages:
error:14094418:SSL routines:SSL3_READ_BYTES:tlsv1 alert unknown ca in /home/orgjvpwd/public_html/user_account/video-server/test2/vendor/workerman/workerman/Connection/TcpConnection.php on line 391

SSL Handshake fail.
Buffer:
client:217.77.212.188:29684 gateway:127.0.0.1:7272 client_id:7f00000108fc00000001 onClose:''

@walkor
Copy link
Owner

walkor commented May 18, 2017

Looks like the certificate is invalid.

@MaksimDzhangirov
Copy link
Author

What program you use to generate certificate? I use openssl and script make-certs.sh from this page http://stackoverflow.com/questions/19665863/how-do-i-use-a-self-signed-certificate-for-a-https-node-js-server.

@walkor
Copy link
Owner

walkor commented May 18, 2017

I purchased the certificate from aliyun.com.

@MaksimDzhangirov
Copy link
Author

Thanks. Problem was resolved.

@walkor walkor closed this as completed May 18, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants