Skip to content

Commit bfbe06c

Browse files
committed
Compilation fixes for OpenSSL 1.1
1 parent 9d6bf8c commit bfbe06c

File tree

2 files changed

+20
-7
lines changed

2 files changed

+20
-7
lines changed

src/mongo/crypto/crypto_openssl.cpp

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,19 +34,27 @@ namespace crypto {
3434
* Computes a SHA-1 hash of 'input'.
3535
*/
3636
bool sha1(const unsigned char* input, const size_t inputLen, unsigned char* output) {
37-
EVP_MD_CTX digestCtx;
38-
EVP_MD_CTX_init(&digestCtx);
39-
ON_BLOCK_EXIT(EVP_MD_CTX_cleanup, &digestCtx);
37+
EVP_MD_CTX *digestCtx = EVP_MD_CTX_create();
38+
if (!digestCtx) {
39+
return false;
40+
}
41+
42+
EVP_MD_CTX_init(digestCtx);
43+
#if OPENSSL_VERSION_NUMBER < 0x10100000L
44+
ON_BLOCK_EXIT(EVP_MD_CTX_destroy, digestCtx);
45+
#else
46+
ON_BLOCK_EXIT(EVP_MD_CTX_free, digestCtx);
47+
#endif
4048

41-
if (1 != EVP_DigestInit_ex(&digestCtx, EVP_sha1(), NULL)) {
49+
if (1 != EVP_DigestInit_ex(digestCtx, EVP_sha1(), NULL)) {
4250
return false;
4351
}
4452

45-
if (1 != EVP_DigestUpdate(&digestCtx, input, inputLen)) {
53+
if (1 != EVP_DigestUpdate(digestCtx, input, inputLen)) {
4654
return false;
4755
}
4856

49-
return (1 == EVP_DigestFinal_ex(&digestCtx, output, NULL));
57+
return (1 == EVP_DigestFinal_ex(digestCtx, output, NULL));
5058
}
5159

5260
/*

src/mongo/util/net/ssl_manager.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -628,7 +628,12 @@ bool SSLManager::_initSSLContext(SSL_CTX** context, const Params& params) {
628628

629629
bool SSLManager::_setSubjectName(const std::string& keyFile, std::string& subjectName) {
630630
// Read the certificate subject name and store it
631-
BIO* in = BIO_new(BIO_s_file_internal());
631+
BIO* in;
632+
#if OPENSSL_VERSION_NUMBER < 0x10100000L
633+
in = BIO_new(BIO_s_file_internal());
634+
#else
635+
in = BIO_new(BIO_s_file());
636+
#endif
632637
if (NULL == in) {
633638
error() << "failed to allocate BIO object: " << getSSLErrorMessage(ERR_get_error()) << endl;
634639
return false;

0 commit comments

Comments
 (0)