Closed
Description
Hi!
I would like to exchange some data on a stream before enabling TLS on it. Currently, the SecureConnector doesn't allow this, and there is no clean way of enabling TLS on Streams after the connection.
Use cases:
- Supporting HTTP proxy CONNECT (required to implement HTTPS proxy support in http-client)
- Supporting SMTP STARTTLS
I'm going to implement this, however I would like your opinion on these solutions:
-
Add a DelayedSecureConnector class. Its create() method would result in a DelayedSecureStream instance, with a connect() method
-
Add a createDelayed() method on SecureConnector, returning the stream and a callback that would allow to enable TLS. Also add a SecureConnectorInterface.
list ($stream, $enableTLS) = $connector->connectDelayed(); // Do something with the stream // Then, enable TLS: $enableTLS()->then(...);
-
Add a "prologue" callback argument to create(), allowing the callback to manipulate the stream before encryption is enabled
WDYT ?