Skip to content

Add TLS/SSL support #342

Open
Open
@iggyvolz

Description

@iggyvolz

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:

$socket = Network\Internal\socket_connect("tcp://{$host}:{$port}", $context, $timeout);
. However there are also several settings in the SSL context https://www.php.net/manual/en/context.ssl.php so I could see this going into ConnectOptions (or a separate SSLConnectOptions within ConnectOptions).

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.

Metadata

Metadata

Assignees

Labels

Priority: MediumThis issue may be useful, and needs some attention.Status: AcceptedIt's clear what the subject of the issue is about, and what the resolution should be.Type: EnhancementMost issues will probably ask for additions or changes.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions