Skip to content

Commit 4a01ddf

Browse files
rdlowreylstrojny
authored andcommitted
Added ssl context option, "disable_compression"
The CRIME attack vector exploits TLS compression. This patch adds a stream context option allowing servers to disable TLS compression for versions of OpenSSL >= 1.0.0 (which first introduced the SSL_OP_NO_COMPRESSION option). A summary rundown of the CRIME attack can be found at https://community.qualys.com/blogs/securitylabs/2012/09/14/crime-information-leakage-attack-against-ssltls Thanks to @DaveRandom for pointing out the relevant section of code.
1 parent bb4d11b commit 4a01ddf

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

ext/openssl/xp_ssl.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -395,6 +395,18 @@ static inline int php_openssl_setup_crypto(php_stream *stream,
395395
}
396396
#endif
397397

398+
#if OPENSSL_VERSION_NUMBER >= 0x10000000L
399+
{
400+
zval **val;
401+
402+
if (stream->context && SUCCESS == php_stream_context_get_option(
403+
stream->context, "ssl", "disable_compression", &val) &&
404+
zval_is_true(*val)) {
405+
SSL_CTX_set_options(sslsock->ctx, SSL_OP_NO_COMPRESSION);
406+
}
407+
}
408+
#endif
409+
398410
sslsock->ssl_handle = php_SSL_new_from_context(sslsock->ctx, stream TSRMLS_CC);
399411
if (sslsock->ssl_handle == NULL) {
400412
php_error_docref(NULL TSRMLS_CC, E_WARNING, "failed to create an SSL handle");

0 commit comments

Comments
 (0)