diff --git a/src/ssl/Ssl.c b/src/ssl/Ssl.c
index 6501f25..9c24ad5 100644
--- a/src/ssl/Ssl.c
+++ b/src/ssl/Ssl.c
@@ -302,8 +302,8 @@ static boolean_t _retry(int socket, int *timeout, int (*callback)(int socket, ti
 
 
 #if (OPENSSL_VERSION_NUMBER < 0x10100000L) || defined(LIBRESSL_VERSION_NUMBER)
-static unsigned long _threadID() {
-        return (unsigned long)Thread_self();
+static void _threadID(CRYPTO_THREADID *id) {
+        CRYPTO_THREADID_set_numeric(id, (unsigned long)Thread_self());
 }
 
 
@@ -482,7 +482,7 @@ void Ssl_start() {
         instanceMutexTable = CALLOC(locks, sizeof(Mutex_T));
         for (int i = 0; i < locks; i++)
                 Mutex_init(instanceMutexTable[i]);
-        CRYPTO_set_id_callback(_threadID);
+        CRYPTO_THREADID_set_callback(_threadID);
         CRYPTO_set_locking_callback(_mutexLock);
 #endif
         if (File_exist(URANDOM_DEVICE))
@@ -496,7 +496,7 @@ void Ssl_start() {
 
 void Ssl_stop() {
 #if (OPENSSL_VERSION_NUMBER < 0x10100000L) || defined(LIBRESSL_VERSION_NUMBER)
-        CRYPTO_set_id_callback(NULL);
+        CRYPTO_THREADID_set_callback(NULL);
         CRYPTO_set_locking_callback(NULL);
         for (int i = 0; i < CRYPTO_num_locks(); i++)
                 Mutex_destroy(instanceMutexTable[i]);
@@ -510,7 +510,7 @@ void Ssl_stop() {
 
 void Ssl_threadCleanup() {
 #if (OPENSSL_VERSION_NUMBER < 0x10100000L) || defined(LIBRESSL_VERSION_NUMBER)
-        ERR_remove_state(0);
+        ERR_remove_thread_state(NULL);
 #endif
 }
 
