Skip to content

STARTTLS support / inband connection upgades for WiFiSecureClient #9099

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
1 task done
dirkx opened this issue Jan 14, 2024 · 5 comments
Closed
1 task done

STARTTLS support / inband connection upgades for WiFiSecureClient #9099

dirkx opened this issue Jan 14, 2024 · 5 comments
Labels
Type: Feature request Feature request for Arduino ESP32

Comments

@dirkx
Copy link
Contributor

dirkx commented Jan 14, 2024

Related area

Protocols such as SMTP, XMPP, IMAP, FTP, IRC, posgress, mysql, nntp, lmtp, sieve and ldap

Hardware specification

Whole ESP32 range

Is your feature request related to a problem?

Protocols such as SMTP, XMPP, IMAP, FTP, IRC, posgress, mysql, nntp, lmtp, sieve and ldap allow for a connection to be started in the clear; and then, after some in-the-clear, capability exchange; an 'upgrade' to SSL or TLS.

This means that you start the connection in the clear; as a normal WiFiClient like connection. At some point conclude that you can request SSL, and only then start the SSL or TLS negotiation.

This is currently not possible with WiFiClientSecure as it goes straight into negotiation after the TCP connect.

Describe the solution you'd like

The option to do the connect in two phases; with a startSSL/startTLS (e.g. as in https://www.openssl.org/docs/man1.0.2/man1/openssl-s_client.html its starttls flag (or the equivalent in stunnel, socat, etc)).

Follows the stunnel/socat/openssl standard.

Describe alternatives you've considered

Replacing all of WifiSecureConnect or writing this in raw mbedtls.

Additional context

No response

I have checked existing list of Feature requests and the Contribution Guide

  • I confirm I have checked existing list of Feature requests and Contribution Guide.
@lbernstone
Copy link
Contributor

Is this an Arduino standard, or something you would see implemented as an entirely new class?

@dirkx
Copy link
Contributor Author

dirkx commented Jan 14, 2024

Given how very common this type of SSL/TLS protocol is (especially also for IoT devices) and given that WiFiClientSecure is a very natural place to do this - I would suggest to accomplish this as per this patch - as a backward compatible 'extra' in the existing WiFiClientSecure class.

I.e. only have this activate if the user calls the

	client.setPlainStart();

as per PR-9100. So it becomes easy to merge into existing protocol code. Because the downside of a new sort of class is that it is harder to switch. And that is often what needs to happen in code - e.g. based on a user configuration or based on a service-discovery. And if this were a separate class - the application would have to create two code-paths (or 4); rather than just a simple (if (setting | capability-reported-bysever) ... client.setPlainStart(); ... client.StartTLS();) on the same class.

@lbernstone
Copy link
Contributor

lbernstone commented Jan 14, 2024

On first look into the code, it seems like it should be possible to pass in an existing WiFiClient on a new object, attempt to initialize ssl_client on that same socket, and then mark the WiFiClient as not connected. Does that make more sense than having it a method of WiFiClient?
You (or the protocol library) will need to handle the negotiation to get to the point it is ready to start SSL, and the TLS itself will need to be a straight forward tunnel.

@dirkx
Copy link
Contributor Author

dirkx commented Jan 14, 2024 via email

@Parsaabasi
Copy link

Hello,

Due to the overwhelming volume of issues currently being addressed, we have decided to close the previously received tickets. If you still require assistance or if the issue persists, please don't hesitate to reopen the ticket.

Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Feature request Feature request for Arduino ESP32
Projects
Development

No branches or pull requests

3 participants