diff --git a/lib/crypto/utils.cpp b/lib/crypto/utils.cpp
index 82cd77434027be8bc79c0d105d36189950c1b14c..cd5b79e26f7425a3dabf8b50d3e83e8fcee73878 100644
--- a/lib/crypto/utils.cpp
+++ b/lib/crypto/utils.cpp
@@ -141,7 +141,11 @@ sha256(const std::string &data)
         bool success = false;
         std::string hashed;
 
+#if OPENSSL_VERSION_NUMBER < 0x10100000L
+        EVP_MD_CTX *context = EVP_MD_CTX_create();
+#else
         EVP_MD_CTX *context = EVP_MD_CTX_new();
+#endif
 
         if (context != NULL) {
                 if (EVP_DigestInit_ex(context, EVP_sha256(), NULL)) {
@@ -156,7 +160,11 @@ sha256(const std::string &data)
                         }
                 }
 
+#if OPENSSL_VERSION_NUMBER < 0x10100000L
+                EVP_MD_CTX_destroy(context);
+#else
                 EVP_MD_CTX_free(context);
+#endif
         }
 
         if (success)