-
Notifications
You must be signed in to change notification settings - Fork 7.9k
By default any TLS method should be used, not TLSv1.0 only #2518
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
Conversation
I find using the |
@DennisBirkholz You're right, I've just updated it. We should probably also think about deprecating |
Which SSL/TLS versions specifically does this allow? Only TLS or also SSLv3? |
I've reported this October last year: https://bugs.php.net/bug.php?id=73388 |
@nikic It allows any TLS version now instead of just TLSv1.0 previously. |
@nikic It accepts just TLS 1.0 by default and allows explicitly setting other protocols in @kelunik I think it makes sense to do it for 7.2. The only problem that I see is that some clients connecting to the old servers needed explicitly specify TLS 1.0 as they didn't work with the new version and the connection hanged (due to some issues with old OpenSSL version IIRC) so it would break. It might have been reason why it was reverted in 5.6 but going forward I think we should change it to 7.2 and not limit it to 1.0 by default. Btw. this needs a test! |
That were my exact question - would this change cause PHP to the best TLS available, and then downgrade if not? Fe if a server supports TLS 1.0 only, and PHP would start with TLS 1.2 and then step down to try the other supported? Probably some stats were to lookup as well, which i've also asked on ML. Fe I'm reading these https://jve.linuxwall.info/blog/index.php?post/2016/08/04/TLS-stats-from-1.6-billion-connections-to-mozilla.org where the one says browsers prefer TLS 1.2, but the other tells servers still support TLS 1.0 to a huge extent. Not sure how these stats are representative. Probably one should do more research. In any case, probably if the internet goes wild, we should of course keep up. Still, it doesn't look like there's an urgent action need, so there should be tests and possible other evaluations, so then we provide the most comfortable solution to the user land. Thanks. |
@weltling Browsers and servers prefer TLS 1.2, but support 1.0 for older clients that aren't capable of TLS 1.2. The used version is negotiated during the handshake. We already migrated the
|
@kelunik yeah, the question is - if a server supports TLS 1.0 only, the connection might fail with a client advertising TLS 1.2, so in that case we break the backward compatibility in the other direction. Fe a server like this one https://www.ssllabs.com/ssltest/analyze.html?d=ssb.epcc.edu. It's kinda expected from github to behave more or less correct, so it's not quite fair to use it for the tests. We have to care also about servers with no TLS 1.2 support and the protocol intolerance, "version negotiated during the handshake" is an ideal case. Perhaps, if TLS 1.2 indeed becomes that wide spread today, the simplest would be to use the exact TLS 1.2 as default in PHP 7.2, other TLS protocols can be still used by the explicit scheme. Or maybe even - use TLS 1.2 first, and then retry with TLS 1.0. Not exactly the unsafe thing browsers do with retrying literally anything possible and would be safe enough with only one possible connection retry, so good from the perf perspective, too. Leaving the decision up to the linked SSL library can per se not guarantee the expected behaviors. Thanks. |
@weltling I'll try to get a list of servers and do some tests, but the server you mentioned doesn't connect with the current version of PHP regardless of the change. |
Maybe it would be better to deprecate all tls*:// streams and have just ssl:// and possibly later add and support only min and max proto option that I suggested in the bug report. Currently the naming is just too confusing and it's true that if we change tls:// we might just break some apps. The |
@bukka If we do that, then we should disable SSL for |
@kelunik SSL is already disabled, isn't it? |
From what I see, your changes are just making |
Ah I see, I missed that |
@kelunik it depends on the linked SSL lib abilities, I can connect to that host from several Linux machines disregarding the PHP version. Earlier PHP Windows builds work too, while the more or less recent don't - because after DROWN OpenSSL disabled weak ciphers by default and we use default build options. Haven't tried LibreSSL, though, no plan yet about it. Thanks. |
@kelunik with OpenSSL 1.0.1m and on, or 1.0.2g, vanilla build, PHP connects to that host. Fe OpenSSL 1.0.2g is delivered in PHP 7.0.5 for Windows. OpenSSL 1.0.2j vanilla build already refuses, fe in PHP 7.0.13 Windows build. On Linux the situation is a bit different, as also to see from your link - a particular distribution can decide, which ciphers to use in PHP. Also, even we define the list, there's no guarantee it is present in the linked SSL lib, and vice versa. Fe where in PHP we block RC4, linked OpenSSL might still provide another cipher supported by the server, where the OPenSSL console client still is able to connect like Thanks. |
So we now have a confusing Proposing deprecating tls:// and keep ssl:// isn't going to solve the confusion, even with proper documentation. It's just counter-intuitive... This could only be implemented 'safe' (with no developer confusing) if tls:// is removed, and not only deprecated. This would be an even more BC-break than changing I don't understand why bad behaviour is supported with BC. As I mentioned in the bugreport, we started using The world is moving to TLS 1.2 only and the PHP TLS constant does not support it by default. I think a BC break is allowed here because it affects security, so we should design an optimal solution:
When you need support for old TLS version (or have handshake downgrade problems), use one of the specific We should not focus on hosts like https://www.ssllabs.com/ssltest/analyze.html?d=ssb.epcc.edu This server has rating F, SSLv2 still enabled etc. etc. There is no 'secure' in their SSL config. The used cipher 3DES_EDE_CBC is not supported in OpenSSL 1.1 anymore. |
@arjenschol I think it might be a bit early to deprecate older constants like I've just opened a RFC for this: https://wiki.php.net/rfc/improved-tls-constants |
I've just changed |
Two weeks have passed, the RFC is now in voting. https://wiki.php.net/rfc/improved-tls-constants |
May I highlight that the constant Note: I also find it quite strange that the constant is not available. If look at the current php-src for 7.1.5 it seems the constant is there but as shown above it cannot be accessed. |
To clarify my comment above, I think the The current documented behavior of the third parameter (
That is simply not true and wrong.
So I'd say we do what was promised in PHP 5.6.0.
But I would also suggest to expose The following code is not preferable. if ($type === null) {
stream_socket_enable_crypto($this->resource, true);
} else {
stream_socket_enable_crypto($this->resource, true, $type);
} I'd rather see the following, which is only possible if stream_socket_enable_crypto($this->resource, true, $type); The above logic probably also holds for the |
@frederikbosch Why is simply passing |
Not only does this default harm security as it disables the newer standard, it is also unexpected.
8cf8c10
to
582ccb2
Compare
@kelunik Passing |
@kelunik Basically SSL (as protocol) is gone by default with regard to streams after this PR is merged. However, we still have to write this. $context = stream_context_create([
'ssl' => []
]); Instead of this. $context = stream_context_create([
'tls' => []
]); Is that logical? |
@frederikbosch Better have one way than two identical ways of doing things. Having both just makes the situation worse. If we're going to switch to |
LGTM! just minor detail that I think most openssl ext test using tabs for tests indent so it would be better to keep it consistent. |
@kelunik yeah, the RFC passed and @bukka is fine, so should be merged in near time. Involve @remicollet and @sgolemon to be aware of this. Thanks. |
@bukka I actually copied the test from the other TLS wrapper tests, which also use spaces. In fact, many of the tests use spaces, but there are also tests with tabs. If we want to have that consistent, we should do that in a separate PR I guess. |
Comment on behalf of pollita at php.net: |
Not only does this default harm security as it disables the newer standard, it is also unexpected.
See also https://externals.io/thread/864.
I think this fix should also be backported to any supported version as it harms security.