gateway开启ssl,客户端连接报错
$context = array(
'ssl' => array(
// 请使用绝对路径
'local_cert' => __DIR__.'/../../../../cert/www.kkk.com.pem', // 也可以是crt文件
'local_pk' => __DIR__.'/../../../../cert/www.kkk.com.key',
'verify_peer' => false,
'allow_self_signed' => true, //如果是自签名证书需要开启此选项
)
);
$gateway = new Gateway("websocket://0.0.0.0:9999",$context);
$gateway->transport = 'ssl';
SSL handshake error: stream_socket_enable_crypto(): SSL operation failed with code 1. OpenSSL Error messages:
error:14094416:SSL routines:ssl3_read_bytes:sslv3 alert certificate unknown
windows系统, gateway-worker版本v3.0.22
为啥不使用nginx?
使用nginx也是报这个错误的
把配置发出来?
证书没问题吗?
server {
listen 443 ssl;
ssl_certificate D:/phpstudy_pro/Extensions/Nginx1.15.11/conf/ssl/certificate.crt;
ssl_certificate_key D:/phpstudy_pro/Extensions/Nginx1.15.11/conf/ssl/private.key;
ssl_session_timeout 5m;
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_prefer_server_ciphers on;
server_name www.mmm.com;
root "D:/phpstudy_pro/WWW/ttt";
location /wss
{
proxy_pass http://127.0.0.1:9999;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
proxy_set_header X-Real-IP $remote_addr;
}
location / {
index index.php index.html error/index.html;
error_page 400 /error/400.html;
error_page 403 /error/403.html;
error_page 404 /error/404.html;
error_page 500 /error/500.html;
error_page 501 /error/501.html;
error_page 502 /error/502.html;
error_page 503 /error/503.html;
error_page 504 /error/504.html;
error_page 505 /error/505.html;
error_page 506 /error/506.html;
error_page 507 /error/507.html;
error_page 509 /error/509.html;
error_page 510 /error/510.html;
include D:/phpstudy_pro/WWW/ttt/nginx.htaccess;
autoindex off;
}
location ~ .php(.*)$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_split_path_info ^((?U).+.php)(/?.+)$;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
include fastcgi_params;
}
}
$context = array(
);
// gateway 进程,这里使用Text协议,可以用telnet测试
$gateway = new Gateway("websocket://0.0.0.0:9999");
//$gateway->transport = 'ssl';
你的证书和域名匹配吗?
ssl_certificate 不是应该用pem吗,你咋用了crt
我检查了
是匹配的
我当初生成证书的时候,common name 就是填写的我的域名
ssl_protocols SSLv3 TLSv1 TLSv1.1 TLSv1.2;
不行
https://www.workerman.net/q/1440
这里可以解答你的问题