Description
Is your feature request related to a problem? Please describe.
The TCP component is incapable of connecting over TLS/SSL (ex. to any HTTPS site)
Describe the solution you'd like
The simplest solution would be to add a flag to Psl\TCP\Connect
which would set the protocol to tls
(tls requested) or tcp
(default/no tls requested) here:
Line 32 in 9f9ddfe
Describe alternatives you've considered
https://www.php.net/manual/en/function.stream-socket-enable-crypto.php appears to allow you to enable TLS after starting a stream, however I was not able to get it to work with HTTPS, so it looks like there's a slightly different effect of stream_context_create("tls://")
vs $stream = stream_context_create("tcp://"); stream_socket_enable_crypto($stream);
- this would allow you to do something like $stream->enableCrypto();
.
Additional context
Running a TLS server is an entirely different beast, because that is going to require loading the certificate in (client certificates also exist but they're far less used 😢). With the complexity here it might make sense to make an entirely separate TLS-over-TCP module.