gpt4 book ai didi

php - Laravel Beyondcode websockets - 如果 verify_peer 为真则不起作用

转载 作者:行者123 更新时间:2023-12-04 13:52:36 25 4
gpt4 key购买 nike

我正在使用包 beyondcode/laravel-websockets .
我的问题是当我设置 'verify_peer' => true 时websocket 不工作,但当值为 false 时这是工作。这里有没有人设法使这个工作?
对于生产网站,我想设置 verify_peertrue以防止中间人攻击。
我有一个网站,比如说 aceraven777.com ,它已经有 SSL已安装(在 cPanel 中启用了 autoSSL)。
在 websockets 配置中,我为证书和私钥输入了相同的路径(cPanel 生成的路径)。
chrome 抛出一个错误:

WebSocket connection to 'wss://aceraven777.com:6001/app/asdfswerqwsafasfd?protocol=7&client=js&version=4.3.1&flash=false' failed: 
createWebSocket @ pusher.min.js:8
这是Firefox中的错误:
Firefox can’t establish a connection to the server at wss://aceraven777.com:6001/app/asdfswerqwsafasfd?protocol=7&client=js&version=4.3.1&flash=false. pusher.min.js:8:6335
以下是我使用的设置:
配置/websockets.php
'ssl' => [
/*
* Path to local certificate file on filesystem. It must be a PEM encoded file which
* contains your certificate and private key. It can optionally contain the
* certificate chain of issuers. The private key also may be contained
* in a separate file specified by local_pk.
*/
'local_cert' => env('LARAVEL_WEBSOCKETS_SSL_LOCAL_CERT', null),

/*
* Path to local private key file on filesystem in case of separate files for
* certificate (local_cert) and private key.
*/
'local_pk' => env('LARAVEL_WEBSOCKETS_SSL_LOCAL_PK', null),

/*
* Passphrase for your local_cert file.
*/
'passphrase' => env('LARAVEL_WEBSOCKETS_SSL_PASSPHRASE', null),

'verify_peer' => true,
],
配置/广播.php
'pusher' => [
'driver' => 'pusher',
'key' => env('PUSHER_APP_KEY'),
'secret' => env('PUSHER_APP_SECRET'),
'app_id' => env('PUSHER_APP_ID'),
'options' => [
'cluster' => env('PUSHER_APP_CLUSTER'),
'host' => env('PUSHER_APP_HOST'),
'port' => env('PUSHER_APP_PORT'),

'useTLS' => true,
'scheme' => 'https',

'curl_options' => [
CURLOPT_SSL_VERIFYHOST => 1,
CURLOPT_SSL_VERIFYPEER => 1,
],
],

// Configuration for laravel mix JS
'mix' => [
'host' => env('MIX_PUSHER_APP_HOST'),
'key' => env('MIX_PUSHER_APP_KEY'),
'cluster' => env('MIX_PUSHER_APP_CLUSTER'),
'port' => env('MIX_PUSHER_APP_PORT'),
],
],

最佳答案

这篇文章前段时间帮我实现了 websockets,尤其是使用 SSL 证书:
https://christoph-rumpel.com/2020/11/laravel-real-time-notifications
您还有 git 存储库告诉您如何使用和不使用 SSL。

关于php - Laravel Beyondcode websockets - 如果 verify_peer 为真则不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68011636/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com