Skip to content

error: self signed certificate issue while implementing WSS signaling server. #1062

Open
@CODEMAX666

Description

Issue: Unable to Resolve "self signed certificate" Error in PHP WebSocket Server

Description

I am experiencing an issue with my PHP WebSocket server where I continually receive the "self signed certificate" error, despite configuring the server to allow self-signed certificates. Below are the details of my setup and the steps I have taken to try to resolve this issue.

use Ratchet\MessageComponentInterface;
use Ratchet\ConnectionInterface;
use React\EventLoop\Loop;
use React\Socket\SocketServer;
use React\Socket\SecureServer;
use Ratchet\Http\HttpServer;
use Ratchet\Server\IoServer;
use Ratchet\WebSocket\WsServer;

$loop = Loop::get();
$webSock = new SocketServer('0.0.0.0:8080', [], $loop);

$secureWebSock = new SecureServer($webSock, $loop, [
    'local_cert' => 'C:\xampp\apache\conf\ssl.crt\ssl.crt',
    'local_pk' => 'C:\xampp\apache\conf\ssl.crt\ssl.key',
    'allow_self_signed' => true,
    'verify_peer' => false,
    'verify_peer_name' => false,
]);

$webServer = new IoServer(
    new HttpServer(
        new WsServer(
            new SignalingServer()
        )
    ),
    $secureWebSock,
    $loop
);

echo "Secure WebSocket server running at wss://0.0.0.0:8080\n";

$webServer->run();

I have tested with wscat.

E:\tmp>wscat -c wss://localhost:8080/check --no-check
Connected (press CTRL+C to quit)
Disconnected (code: 1000, reason: "")

E:\tmp>wscat -c wss://localhost:8080/check
error: self signed certificate

How to solve this problem?
I have also tried with default SSL keys in XAMPP, in that case, I got "error: certificate has expired" error.

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions