-
Notifications
You must be signed in to change notification settings - Fork 29.7k
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
tls.connect Error: self signed certificate when connect to imap.gmail.com:933 #28167
Comments
@nodejs/crypto |
The issue is that Node.js (no longer?) sends a SNI record by default. You can work around it like this: const options = {
port: 993,
host: 'imap.gmail.com',
servername: 'imap.gmail.com', // SNI
};
tls.connect(options, () => { /* ... */ }); It might have been caused by an openssl upgrade because I can reproduce with (GMail helpfully sends back a certificate with |
Thank you. |
Sending SNI on the |
This might be a bug. 11.x and 12.x have the same OpenSSL version, but different behaviour, so it looks like something changed in node, not in openssl:
|
I'm bisecting, maybe I can pinpoint a specific change. |
The reason I mention it is that the stock |
We're offtopic but it's because it was changed in 1.1.1 as per this changelog entry:
|
bisect pointed to 42dbaed, my commit to add TLS1.3 support, and indeed it works with TLS1.2:
However, running with So, this is confirmed as a gmail bug. Possibly, Thoughts? More discussion: https://mta.openssl.org/pipermail/openssl-project/2018-April/000623.html |
I suppose GMail is technically in the right because the spec says that a server MAY require SNI and imap.gmail.com does.... ...although it's "interesting" that it doesn't actually care what you set the servername to: it happily accepts We could turn on SNI by default although that leaks the servername because the SNI payload is unencrypted (and it'll be a while before ESNI is a thing.) |
I guess we have to default to sending a SNI (and mimic what browsers do). It is indeed a data leak, but I guess more services will work with it present than without. BTW, I don't expect ESNI in the current draft form to get any widespread adoption because of it's complexity. |
@silverwind We already mimic what browsers do by defaulting to sending SNI for https (see Agent.prototype.addRequest), so it is only direct use of tls that doesn't set servername. I'll PR a default use of servername to tls.connect (unless someone else beats me to it). |
@sam-github Did you open that PR and if so, can you link to it? |
@bnoordhuis nope, still on my todo list |
Hi! Just to add some clarification here - RFC 8446 section 9.2 says:
ie: The "MAY" only refers to GMail choosing to be strict about this - clients are covered by the "MUST" - so Node's |
What would be the default for |
I'm not familiar with https but servername is calculated here and yes, we derive it from the TBH I only recently found tls doesn't set SNI by default, I can agree it's not intuitive but it seems to be conventional. Maybe we could mention it more explicitely in the docs? |
Add a note warning users that when using tls.connect(), the `servername` option must be set explicitely to enable SNI, otherwise the connection could fail. Fixes: nodejs#28167
I propose to add the warning and close this (but regardless, I'm not against changing the default if we decide to do so) |
@edmorley sorry, I hadn't seen your comment...
But that "MUST" only requires implementations to support the use of SNI. We do support it, we just don't enable it by default, right? |
@mildsunrise Hi! Yeah I suppose that's technically correct, however I feel like having the default Perhaps the best option is to add a warning to the docs for now, and then in the next Node major make it the default for TLS 1.3 connections only? |
Sorry to bump in. This is the part I'm missing. Make what exactly the default, i.e. what is "it"? |
Current behaviour doesn't match user expectations, that's for sure (but it is spec-compliant imo, since it's the application (i.e. the user) who's in charge of enabling it) I understand you want to enable SNI by default for TLS 1.3 connections? |
I'm not saying that
To hopefully clarify:
Anyway happy to let others make the judgement call on this :-) |
Oh, TLSv1.3 mandates SNI? If you're referring to the paragraph where it says «In the absence of an application profile standard specifying otherwise, a TLS-compliant application MUST implement» like you said it's the application who's responsible of following spec (but yes, I agree that this is a valid reason for us to enable SNI by default). If we want to enable SNI by default, I'd vote we do it on all connections... doing it only for TLSv1.3 could be confusing, IMHO. Edit: The potential for breakage is small by itself, but as @bnoordhuis said we'll be suddenly leaking data and this could break applications that run behind an SNI-based firewall, for instance. |
I agree, I only mentioned that as a way to mitigate the privacy concerns for pre -TLSv1.3 use-cases, but (a) it would be confusing, (b) in those cases users could always disable it explicitly if desired I suppose. |
RFC 8446 lists SNI in the mandatory-to-implement extensions section but nowhere does it seem to say TLSv1.3 clients MUST use SNI. SHOULD yes, MUST no. https://tools.ietf.org/html/rfc8446#section-4.4.2.2:
https://tools.ietf.org/html/rfc8446#section-9.2:
(server_name = SNI) |
Warning added! On whether to enable SNI by default, I'd recommend to open a PR or separate issue to continue discussion there |
Add a note warning users that when using tls.connect(), the `servername` option must be set explicitely to enable SNI, otherwise the connection could fail. PR-URL: #33855 Fixes: #28167 Co-authored-by: Denys Otrishko <shishugi@gmail.com> Reviewed-By: Robert Nagy <ronagy@icloud.com> Reviewed-By: Denys Otrishko <shishugi@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Add a note warning users that when using tls.connect(), the `servername` option must be set explicitely to enable SNI, otherwise the connection could fail. PR-URL: #33855 Fixes: #28167 Co-authored-by: Denys Otrishko <shishugi@gmail.com> Reviewed-By: Robert Nagy <ronagy@icloud.com> Reviewed-By: Denys Otrishko <shishugi@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Add a note warning users that when using tls.connect(), the `servername` option must be set explicitely to enable SNI, otherwise the connection could fail. PR-URL: #33855 Fixes: #28167 Co-authored-by: Denys Otrishko <shishugi@gmail.com> Reviewed-By: Robert Nagy <ronagy@icloud.com> Reviewed-By: Denys Otrishko <shishugi@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Add a note warning users that when using tls.connect(), the `servername` option must be set explicitely to enable SNI, otherwise the connection could fail. PR-URL: #33855 Fixes: #28167 Co-authored-by: Denys Otrishko <shishugi@gmail.com> Reviewed-By: Robert Nagy <ronagy@icloud.com> Reviewed-By: Denys Otrishko <shishugi@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Add a note warning users that when using tls.connect(), the `servername` option must be set explicitely to enable SNI, otherwise the connection could fail. PR-URL: #33855 Fixes: #28167 Co-authored-by: Denys Otrishko <shishugi@gmail.com> Reviewed-By: Robert Nagy <ronagy@icloud.com> Reviewed-By: Denys Otrishko <shishugi@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Error: self signed certificate
When?
looks happened connect to imap.gmail.com:933 only.
imap.mail.me.com have no same issue.
I checked tls connect with openssl command to imap.gmail.com at same OS, looks Good. It have not Man-in-the-middle attack OS. The code have no problem when I back NodeJS to v11.
The text was updated successfully, but these errors were encountered: