Skip to content

Commit

Permalink
Set SSL_MODE_RELEASE_BUFFERS by default
Browse files Browse the repository at this point in the history
  • Loading branch information
alexcrichton committed Sep 15, 2017
1 parent c800ab9 commit 68a30c2
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion openssl/src/ssl/connector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use error::ErrorStack;
use ssl::{self, SslMethod, SslContextBuilder, SslContext, Ssl, SSL_VERIFY_PEER, SslStream,
HandshakeError};
use pkey::PKeyRef;
use version;
use x509::X509Ref;

#[cfg(ossl101)]
Expand Down Expand Up @@ -39,8 +40,17 @@ fn ctx(method: SslMethod) -> Result<SslContextBuilder, ErrorStack> {
opts |= ssl::SSL_OP_CIPHER_SERVER_PREFERENCE;
ctx.set_options(opts);

let mode = ssl::SSL_MODE_AUTO_RETRY | ssl::SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER |
let mut mode = ssl::SSL_MODE_AUTO_RETRY |
ssl::SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER |
ssl::SSL_MODE_ENABLE_PARTIAL_WRITE;

// This is quite a useful optimization for saving memory, but historically
// caused CVEs in OpenSSL pre-1.0.1h, according to
// https://bugs.python.org/issue25672
if version::number() >= 0x1000108f {
mode |= ssl::SSL_MODE_RELEASE_BUFFERS;
}

ctx.set_mode(mode);

Ok(ctx)
Expand Down

0 comments on commit 68a30c2

Please sign in to comment.