-
Notifications
You must be signed in to change notification settings - Fork 7.8k
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
Streams: Configure crypto method for ssl:// transports #469
Conversation
crypto method (SSLv3, SSLv2 etc.) by calling stream_context_set_option($ctx, "ssl", "crypto_method", $crypto_method) where $crypto_method can be one of STREAM_CRYPTO_METHOD_SSLv2_CLIENT, STREAM_CRYPTO_METHOD_SSLv3_CLIENT, STREAM_CRYPTO_METHOD_SSLv23_CLIENT or STREAM_CRYPTO_METHOD_TLS_CLIENT. SSLv23 remains the default crypto method. This change makes it possible to fopen() SSL URLs that are only provided using SSL v3.
Actually, after further thought I don't believe this PR is necessary because if you need SSLv3 you can simply use the |
Another concern I have with this is ...
(source) I'm not sure making it easier to implement insecure encryption protocols is really a good idea. |
@rdlowrey There are plenty of (dumb) SSLv3 services. sslv3:// is for fsockopen() and this PR for fopen() using a stream context. I'd like to see a test coming with this patch, though. |
The test regards @mj though :) |
I'll look into it. |
@m6w6 I get that. I just wanted to raise the point because SSLv3 is hopelessly insecure and TLSv1.0 has been around since January 1999. If a service requires SSLv3 you should (1) demand the service upgrade its capabilities or (2) not use the service because it might as well not be encrypted at all. TBH, I'm not sure we should be subsidizing this sort of negligence on the part of service providers. The bigger issue here is that |
I understand your concerns, but we provide a tool for software development for people to get their job done. We're not a religion or a law making entitity :) |
Regardless of how you feel about subsidizing insecure behavior SSLv3 is already supported. Without a substantive use-case I don't see how this addition is justifiable. The only thing this patch does is add overhead without adding additional support. Once you understand how OpenSSL interprets the |
Ok well, then show us how you fetch from e.g. https://tst.eboekhuis.nl with fopen or file_get_contents. |
I stand corrected. You can count me in for support on this feature :) I was working on assumptions from the OpenSSL docs here:
With that in mind the following connects successfully (but fails with the SSLv23 method): <?php
$client = stream_socket_client('tcp://194.229.60.172:443');
if (!stream_socket_enable_crypto($client, TRUE, STREAM_CRYPTO_METHOD_SSLv3_CLIENT)) {
die("Failed enabling crypto!\n");
}
printf("wrote %d bytes to socket\n", fwrite($client, "GET / HTTP/1.0\r\n\r\n"));
while (!feof($client)) {
echo fread($client, 8192);
} Interestingly the server immediately terminates the connection after you write data and the same behavior is seen when connecting via the openssl binary: openssl s_client -connect 194.229.60.172:443 -ssl3 Recently distros have started disabling SSLv2 (at least in their packaged openssl libs). I suspect that the gradual phasing out of SSLv2 will cause more breakage going forward as the SSLv2 hello messages sent with the SSLv23 client method are no longer understood. FWIW the different browsers I've tried also fail to successfully resolve the encrypted version of the link you provided. I'm also curious as to why the remote server immediately severs the connection as soon as data is written by the client. |
You see, the real world is broken and we have to support those poor souls working with it :) Anyway for this particular broken service, you've to know that it additionally wants RC4 cipher suite.
|
Yes :) Another thing we should look at in relation to this issue is changing the default encryption wrapper from The problem of missing SSLv2 support is likely to grow more prevalent as the SSLv2 protocol dies off. Allowing context-level specification for the specific protocol is fine, but using In any case I'll soon be posting an RFC with lots of ext/openssl improvements. Among other things it adds support for both TLSv1.1 and TLSv1.2 when built against OpenSSL >= 1.0.1. With this change the |
Alright then, I want to merge it into PHP-5.5 when there's a test from @mj |
@m6w6, there's a test case available now. |
Streams for ssl:// transports can now be configured to use a specific crypto method (SSLv3, SSLv2 etc.) by calling
where
$crypto_method
can be one ofSTREAM_CRYPTO_METHOD_SSLv2_CLIENT
STREAM_CRYPTO_METHOD_SSLv3_CLIENT
STREAM_CRYPTO_METHOD_SSLv23_CLIENT
STREAM_CRYPTO_METHOD_TLS_CLIENT
SSLv23 remains the default crypto method.
Among other situations, this change makes it possible to
fopen()
URLs on an SSL server that only supports SSL v3: Previously the streams behind this always usedSTREAM_CRYPTO_METHOD_SSLv23_CLIENT
which can now be overridden using the context option.