ssl problems
- Dominant language
- PHP
- Stars
- 11.6k
- Forks
- 2.2k
- Avg merge
- 11h 30m
- Merged PRs (30d)
- 3
Description
Hi,
I have a few questions about ssl. Is ssl option possible with websocket/http and tcp? Any other protocol?
I`m banging my head with certs. I managed to get it working with self-signed cert, code is below.
First problem is that if I use on server example.crt and on client secure.pem or secret-cert (which are totaly
diffrent certs) it still works. How can I check if cert provided is *same* as server cert? Do you have any
client/server example code from your own?
Thanks for great project!
client code:
```
$context = array(
'ssl' => array(
'local_cert' => './example.crt', // __DIR__ . '/path',
'local_pk' => './example.key', // __DIR__ . '/path',
//'local_cert' => './secret-cert.pem',
//'local_pk' => './secret-priv.key',
//'local_cert' => './secure.pem',
//'passphrase' => 'abracadabra',
'allow_self_signed' => true,
'verify_peer' => true,
)
);
if ($socket = stream_socket_client('ssl://'.$host.':'.$port,
$errno, $errstr, 30, STREAM_CLIENT_CONNECT, stream_context_create($context))) {
//fwrite($socket, PHP_EOL.PHP_EOL);
//echo fread($socket, 8192);
//fwrite($socket, 'hello world!'.PHP_EOL);
while (!feof($socket)) echo fgets($socket, 1024);
fclose($socket);
}
```
server code:
```
$context = array(
'ssl' => array(
//'ciphers' => 'DHE-RSA-AES256-SHA:LONG-CIPHER',
'local_cert' => './example.crt', ///'./secret-cert.pem', // __DIR__ . '/path',
'local_pk' => './example.key', ///'./secret-priv.key', // __DIR__ . '/path',
/*'local_cert' => './secure.pem',
'passphrase' => 'abracadabra',*/
'allow_self_signed' => true,
'verify_peer' => true,
)
);
// Create A Worker and listen on port,not specified protocol
$worker = new Worker('http://0.0.0.0:58000', $context);
// Enable SSL. WebSocket+SSL means that Secure WebSocket (wss://).
// The similar approaches for Https etc.
$worker->transport = 'ssl';
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.