Skip to content

Commit

Permalink
Added ssl context option, "disable_compression"
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
rdlowrey authored and lstrojny committed Jan 30, 2013
1 parent bb4d11b commit 4a01ddf
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions ext/openssl/xp_ssl.c
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,18 @@ static inline int php_openssl_setup_crypto(php_stream *stream,
}
#endif

#if OPENSSL_VERSION_NUMBER >= 0x10000000L
{
zval **val;

if (stream->context && SUCCESS == php_stream_context_get_option(
stream->context, "ssl", "disable_compression", &val) &&
zval_is_true(*val)) {
SSL_CTX_set_options(sslsock->ctx, SSL_OP_NO_COMPRESSION);
}
}
#endif

sslsock->ssl_handle = php_SSL_new_from_context(sslsock->ctx, stream TSRMLS_CC);
if (sslsock->ssl_handle == NULL) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "failed to create an SSL handle");
Expand Down

0 comments on commit 4a01ddf

Please sign in to comment.