File compression_methods_switch.patch of Package openssl

diff -rNU 30 ../openssl-1.0.1n-o/doc/ssl/SSL_COMP_add_compression_method.pod ./doc/ssl/SSL_COMP_add_compression_method.pod
--- ../openssl-1.0.1n-o/doc/ssl/SSL_COMP_add_compression_method.pod	2015-06-11 16:01:49.000000000 +0200
+++ ./doc/ssl/SSL_COMP_add_compression_method.pod	2015-06-12 04:35:06.000000000 +0200
@@ -14,57 +14,76 @@
 SSL_COMP_add_compression_method() adds the compression method B<cm> with
 the identifier B<id> to the list of available compression methods. This
 list is globally maintained for all SSL operations within this application.
 It cannot be set for specific SSL_CTX or SSL objects.
 =head1 NOTES
 The TLS standard (or SSLv3) allows the integration of compression methods
 into the communication. The TLS RFC does however not specify compression
 methods or their corresponding identifiers, so there is currently no compatible
 way to integrate compression with unknown peers. It is therefore currently not
 recommended to integrate compression into applications. Applications for
 non-public use may agree on certain compression methods. Using different
 compression methods with the same identifier will lead to connection failure.
 An OpenSSL client speaking a protocol that allows compression (SSLv3, TLSv1)
 will unconditionally send the list of all compression methods enabled with
 SSL_COMP_add_compression_method() to the server during the handshake.
 Unlike the mechanisms to set a cipher list, there is no method available to
 restrict the list of compression method on a per connection basis.
 An OpenSSL server will match the identifiers listed by a client against
 its own compression methods and will unconditionally activate compression
 when a matching identifier is found. There is no way to restrict the list
 of compression methods supported on a per connection basis.
 The OpenSSL library has the compression methods B<COMP_rle()> and (when
 especially enabled during compilation) B<COMP_zlib()> available.
+And, there is an environment variable to switch the compression
+methods off and on. In default the compression is off to mitigate 
+the so called CRIME attack ( CVE-2012-4929). If you want to enable 
+compression again set OPENSSL_NO_DEFAULT_ZLIB to "no".
+The variable can be switched on and off at runtime; when this variable
+is set "no" compression is enabled, otherwise no, for example:
+in shell 'export OPENSSL_NO_DEFAULT_ZLIB=no'
+or in C to call
+int setenv(const char *name, const char *value, int overwrite); and
+int unsetenv(const char *name);
+Note: This reverts the behavior of the variable as it was before!
+And pay attention that this freaure is temporary, it maybe changed by
+the following updates.
 =head1 WARNINGS
 Once the identities of the compression methods for the TLS protocol have
 been standardized, the compression API will most likely be changed. Using
 it in the current state is not recommended.
 SSL_COMP_add_compression_method() may return the following values:
 =over 4
 =item Z<>0
 The operation succeeded.
 =item Z<>1
 The operation failed. Check the error queue to find out the reason.
 =head1 SEE ALSO
diff -rNU 30 ../openssl-1.0.1n-o/ssl/ssl_ciph.c ./ssl/ssl_ciph.c
--- ../openssl-1.0.1n-o/ssl/ssl_ciph.c	2015-06-11 16:01:49.000000000 +0200
+++ ./ssl/ssl_ciph.c	2015-06-12 04:38:47.000000000 +0200
@@ -431,64 +431,70 @@
         ssl_mac_secret_size[SSL_MD_GOST89MAC_IDX] = 32;
     ssl_digest_methods[SSL_MD_SHA256_IDX] = EVP_get_digestbyname(SN_sha256);
     ssl_mac_secret_size[SSL_MD_SHA256_IDX] =
     ssl_digest_methods[SSL_MD_SHA384_IDX] = EVP_get_digestbyname(SN_sha384);
     ssl_mac_secret_size[SSL_MD_SHA384_IDX] =
 static int sk_comp_cmp(const SSL_COMP *const *a, const SSL_COMP *const *b)
     return ((*a)->id - (*b)->id);
 static void load_builtin_compressions(void)
     int got_write_lock = 0;
     if (ssl_comp_methods == NULL) {
         got_write_lock = 1;
         if (ssl_comp_methods == NULL) {
             SSL_COMP *comp = NULL;
+            const char *nodefaultzlib;
             ssl_comp_methods = sk_SSL_COMP_new(sk_comp_cmp);
-            if (ssl_comp_methods != NULL) {
+/*             if (ssl_comp_methods != NULL) { */
+            /* The default is "no" compression to avoid CRIME/BEAST */
+            nodefaultzlib = getenv("OPENSSL_NO_DEFAULT_ZLIB");
+            if (    ssl_comp_methods != NULL &&
+                    nodefaultzlib &&
+                    strncmp( nodefaultzlib, "no", 2) == 0) {
                 comp = (SSL_COMP *)OPENSSL_malloc(sizeof(SSL_COMP));
                 if (comp != NULL) {
                     comp->method = COMP_zlib();
                     if (comp->method && comp->method->type == NID_undef)
                     else {
                         comp->id = SSL_COMP_ZLIB_IDX;
                         comp->name = comp->method->name;
                         sk_SSL_COMP_push(ssl_comp_methods, comp);
     if (got_write_lock)
 int ssl_cipher_get_evp(const SSL_SESSION *s, const EVP_CIPHER **enc,
                        const EVP_MD **md, int *mac_pkey_type,
                        int *mac_secret_size, SSL_COMP **comp)
     int i;
     const SSL_CIPHER *c;
openSUSE Build Service is sponsored by