Пример #1
1
	void finish() {
		av_lockmgr_register(nullptr);

		CRYPTO_cleanup_all_ex_data();
		FIPS_mode_set(0);
		ENGINE_cleanup();
		CONF_modules_unload(1);
		ERR_remove_state(0);
		ERR_free_strings();
		ERR_remove_thread_state(nullptr);
		EVP_cleanup();

		delete[] _sslLocks;
		_sslLocks = nullptr;

		Platform::ThirdParty::finish();
	}
Пример #2
0
static void SQBIND_Exit_curl()
{
	oexAutoLock ll( _g_curl_lock );
	if ( !ll.IsLocked() ) 
		return;
	
	// Cleanup curl
	curl_global_cleanup();

	// SSL cleanup sequence
	ERR_remove_state( 0 );
//	ENGINE_cleanup();
	CONF_modules_unload( 1 );
	ERR_free_strings();
	EVP_cleanup();
	CRYPTO_cleanup_all_ex_data();
}
Пример #3
0
LWS_VISIBLE void
lws_ssl_context_destroy(struct lws_context *context)
{
	if (context->ssl_ctx)
		SSL_CTX_free(context->ssl_ctx);
	if (!context->user_supplied_ssl_ctx && context->ssl_client_ctx)
		SSL_CTX_free(context->ssl_client_ctx);

#if (OPENSSL_VERSION_NUMBER < 0x01000000) || defined(USE_WOLFSSL)
	ERR_remove_state(0);
#else
	ERR_remove_thread_state(NULL);
#endif
	ERR_free_strings();
	EVP_cleanup();
	CRYPTO_cleanup_all_ex_data();
}
Пример #4
0
static void
openssl_shutdown(void)
{
	CONF_modules_unload(1);
	destroy_ui_method();
	OBJ_cleanup();
	EVP_cleanup();

#ifndef OPENSSL_NO_ENGINE
	ENGINE_cleanup();
#endif

	CRYPTO_cleanup_all_ex_data();
	ERR_remove_thread_state(NULL);
	RAND_cleanup();
	ERR_free_strings();
}
Пример #5
0
int main(void)
	{
	int 	ret = 1;
	BIO	*out;

	out = BIO_new_fp(stdout, BIO_NOCLOSE);
	
	/* enable memory leak checking unless explicitly disabled */
	if (!((getenv("OPENSSL_DEBUG_MEMORY") != NULL) && 
		(0 == strcmp(getenv("OPENSSL_DEBUG_MEMORY"), "off"))))
		{
		CRYPTO_malloc_debug_init();
		CRYPTO_set_mem_debug_options(V_CRYPTO_MDEBUG_ALL);
		}
	else
		{
		/* OPENSSL_DEBUG_MEMORY=off */
		CRYPTO_set_mem_debug_functions(0, 0, 0, 0, 0);
		}
	CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ON);

	ERR_load_crypto_strings();

	/* initialize the prng */
	RAND_seed(rnd_seed, sizeof(rnd_seed));

	/* the tests */
	if (!x9_62_tests(out))  goto err;
	if (!test_builtin(out)) goto err;
	
	ret = 0;
err:	
	if (ret) 	
		BIO_printf(out, "\nECDSA test failed\n");
	else 
		BIO_printf(out, "\nECDSA test passed\n");
	if (ret)
		ERR_print_errors(out);
	CRYPTO_cleanup_all_ex_data();
	ERR_remove_thread_state(NULL);
	ERR_free_strings();
	CRYPTO_mem_leaks(out);
	if (out != NULL)
		BIO_free(out);
	return ret;
	}	
Пример #6
0
void check_finish()
{
	iconv_close(iconv_utf8);
	iconv_close(iconv_ucs2);
	iconv_close(iconv_utf32);
	BN_free(bn_factors);
	ASN1_OBJECT_free(obj_jurisdictionCountryName);
	ASN1_OBJECT_free(obj_jurisdictionLocalityName);
	ASN1_OBJECT_free(obj_jurisdictionStateOrProvinceName);
	ASN1_OBJECT_free(obj_StreetAddress);
	ASN1_OBJECT_free(obj_postalCode);
	ASN1_OBJECT_free(obj_postOfficeBox);
	ASN1_OBJECT_free(obj_anyEKU);
	ASN1_OBJECT_free(obj_IntelAMTvProEKU);
	EVP_cleanup();
	CRYPTO_cleanup_all_ex_data();
}
Пример #7
0
void
dst__openssl_destroy(void) {
	/*
	 * Sequence taken from apps_shutdown() in <apps/apps.h>.
	 */
	if (rm != NULL) {
#if OPENSSL_VERSION_NUMBER >= 0x00907000L
		RAND_cleanup();
#endif
		mem_free(rm);
		rm = NULL;
	}
#if (OPENSSL_VERSION_NUMBER >= 0x00907000L)
	CONF_modules_free();
#endif
	OBJ_cleanup();
	EVP_cleanup();
#if defined(USE_ENGINE)
	if (e != NULL)
		ENGINE_free(e);
	e = NULL;
#if defined(USE_ENGINE) && OPENSSL_VERSION_NUMBER >= 0x00907000L
	ENGINE_cleanup();
#endif
#endif
#if (OPENSSL_VERSION_NUMBER >= 0x00907000L)
	CRYPTO_cleanup_all_ex_data();
#endif
	ERR_clear_error();
#if OPENSSL_VERSION_NUMBER < 0x10100000L
	ERR_remove_state(0);
#endif
	ERR_free_strings();

#ifdef  DNS_CRYPTO_LEAKS
	CRYPTO_mem_leaks_fp(stderr);
#endif

	if (locks != NULL) {
		CRYPTO_set_locking_callback(NULL);
		DESTROYMUTEXBLOCK(locks, nlocks);
		mem_free(locks);
		locks = NULL;
	}
}
Пример #8
0
void cleanupOpenSSL()
{
	if(m_ssl != NULL)
	{
		SSL_shutdown (m_ssl);  /* send SSL/TLS close_notify */
		SSL_free (m_ssl);
		m_ssl = NULL;
	}
	if(m_ctx != NULL)
	{
		SSL_CTX_free (m_ctx);	
		m_ctx = NULL;
		ERR_remove_state(0);
		ERR_free_strings();
		EVP_cleanup();
		CRYPTO_cleanup_all_ex_data();
	}
}
Пример #9
0
/**
 * oh_ssl_finit
 *
 * Finalizes the OpenSSL library. The calls used in this routine releases global
 * data created/initialized by the OpenSSL library.
 *
 * Note that it is the responisbility of the caller of this function to make
 * sure that no other threads are making the OpenSSL library calls. The openhpid
 * should close all the threads and call this function from the main (single)
 * thread.
 *
 * Return value: None
 **/
void oh_ssl_finit(void)
{
        /* TODO: Check whether any other SSL library cleanup should be called */
        thread_cleanup();
        ENGINE_cleanup();
        CONF_modules_unload(0);
        ERR_free_strings();
        EVP_cleanup();
        CRYPTO_cleanup_all_ex_data();
        /* The valgrind is showing possible memory leak by
         * SSL_COMP_get_compression_methods() call.
         *
         * Call to SSL_free_comp_methods() may resolve the memory leak.
         * But not able to find this call in the openssl 0.9.8e
         * TODO: Find whether its a real problem or not
         */

}
Пример #10
0
static void apps_shutdown()
{
#ifndef OPENSSL_NO_ENGINE
    ENGINE_cleanup();
#endif
    destroy_ui_method();
    CONF_modules_unload(1);
#ifndef OPENSSL_NO_COMP
    COMP_zlib_cleanup();
    SSL_COMP_free_compression_methods();
#endif
    OBJ_cleanup();
    EVP_cleanup();
    CRYPTO_cleanup_all_ex_data();
    ERR_remove_thread_state(NULL);
    RAND_cleanup();
    ERR_free_strings();
}
Пример #11
0
	void finish() {
		av_lockmgr_register(nullptr);

		CRYPTO_cleanup_all_ex_data();
#ifndef LIBRESSL_VERSION_NUMBER
		FIPS_mode_set(0);
#endif
		ENGINE_cleanup();
		CONF_modules_unload(1);
		ERR_remove_state(0);
		ERR_free_strings();
		ERR_remove_thread_state(nullptr);
		EVP_cleanup();

		delete[] base::take(_sslLocks);

		Platform::ThirdParty::finish();
	}
Пример #12
0
// .. c:function::
ch_error_t
ch_en_openssl_uninit(void)
//    :noindex:
//
//    see: :c:func:`ch_en_openssl_uninit`
//
// .. code-block:: cpp
//
{
    FIPS_mode_set(0);
    ENGINE_cleanup();
    CONF_modules_unload(1);
    EVP_cleanup();
    CRYPTO_cleanup_all_ex_data();
    ERR_free_strings();
    CONF_modules_free();
    return CH_SUCCESS;
}
/**
 * @see clientlib.h 
 */
void selfTest(){  
  ERR_load_crypto_strings();
  OpenSSL_add_all_algorithms();
  OPENSSL_config(NULL);
  // TODO: do some encryption
  unsigned char data[] = "HelloWorld";
  unsigned char hash[SHA512_DIGEST_LENGTH];
  SHA512(data, sizeof(data), hash);
  int i;
    for (i = 0; i < sizeof(data); i++) {
        printf("%02x ", data[i]);
    }
    printf("\n");
  //
  EVP_cleanup();
  CRYPTO_cleanup_all_ex_data();
  ERR_free_strings();
}
Пример #14
0
int main( int argc, char** argv )
{
	SSTRACE_ARGS args; int rc = 0;

	memset( &args, 0, sizeof( args ) );
	ErrBuffer[0] = 0;

	if( argc < 3 )
	{
		print_usage();
		return 0;
	}

	if( load_args( argc, argv, &args ) != 0 )
	{
		if( strlen( ErrBuffer ) ) 
		{
			fprintf( stderr, ErrBuffer );
		}
		else
		{
			print_usage();
		}

		return 1;
	}

	/* Initialize OpenSSL library before using DSSL! */
	SSL_library_init();	
	OpenSSL_add_all_ciphers();
	OpenSSL_add_all_digests();

	rc = proceed( &args );
	if( rc != 0 )
	{
		if( strlen( ErrBuffer ) ) fprintf( stderr, ErrBuffer );
	}

	/* Cleanup OpenSSL */
	EVP_cleanup();
	CRYPTO_cleanup_all_ex_data();

	return rc;
}
Пример #15
0
/* Global cleanup */
void Curl_ossl_cleanup(void)
{
  /* Free the SSL error strings */
  ERR_free_strings();

  /* EVP_cleanup() removes all ciphers and digests from the
     table. */
  EVP_cleanup();

#ifdef HAVE_ENGINE_cleanup
  ENGINE_cleanup();
#endif

#ifdef HAVE_CRYPTO_CLEANUP_ALL_EX_DATA
  /* this function was not present in 0.9.6b, but was added sometimes
     later */
  CRYPTO_cleanup_all_ex_data();
#endif
}
Пример #16
0
//--------------------------------------------------------------------------------------------------
le_result_t secSocket_Delete
(
    secSocket_Ctx_t* ctxPtr      ///< [INOUT] Secure socket context pointer
)
{
    if (!ctxPtr)
    {
        return LE_BAD_PARAMETER;
    }

    OpensslCtx_t* contextPtr = GetContext(ctxPtr);
    if (!contextPtr)
    {
        return LE_BAD_PARAMETER;
    }

    BIO_free_all(contextPtr->bioPtr);
    contextPtr->bioPtr = NULL;
    SSL_CTX_free(contextPtr->sslCtxPtr);
    contextPtr->sslCtxPtr = NULL;

#if OPENSSL_API_COMPAT < 0x10100000L
#if OPENSSL_API_COMPAT > 0x10002000L
    // In versions of OpenSSL prior to 1.1.0 SSL_COMP_free_compression_methods() freed the
    // internal table of compression methods that were built internally, and possibly augmented
    // by adding SSL_COMP_add_compression_method().
    // However this is now unnecessary from version 1.1.0. No explicit initialisation or
    // de-initialisation is necessary.
    SSL_COMP_free_compression_methods();
#endif
#endif
    EVP_cleanup();
    ERR_free_strings();

    CRYPTO_cleanup_all_ex_data();
#if OPENSSL_VERSION_NUMBER < 0x10100000L
    ERR_remove_state(0);
#endif
    contextPtr->isInit = false;
    le_mem_Release(contextPtr);

    return LE_OK;
}
Пример #17
0
/*
 * called from main.c when opensips exits (main process)
 */
static void mod_destroy(void)
{
	struct tls_domain *d;
	LM_DBG("entered\n");

	if (dom_lock) {
		lock_destroy_rw(dom_lock);
		dom_lock = 0;
	}

	d = tls_server_domains;
	while (d) {
		if (d->ctx)
			SSL_CTX_free(d->ctx);
		lock_destroy(d->lock);
		lock_dealloc(d->lock);
		d = d->next;
	}
	d = tls_client_domains;
	while (d) {
		if (d->ctx)
			SSL_CTX_free(d->ctx);
		lock_destroy(d->lock);
		lock_dealloc(d->lock);
		d = d->next;
	}
	if (tls_default_server_domain.ctx) {
		SSL_CTX_free(tls_default_server_domain.ctx);
	}
	if (tls_default_client_domain.ctx) {
		SSL_CTX_free(tls_default_client_domain.ctx);
	}
	tls_free_domains();

	/* TODO - destroy static locks */

	/* library destroy */
	ERR_free_strings();
	/*SSL_free_comp_methods(); - this function is not on std. openssl*/
	EVP_cleanup();
	CRYPTO_cleanup_all_ex_data();
	return;
}
Пример #18
0
void _mosquitto_net_cleanup(void)
{
#ifdef WITH_TLS
	ERR_remove_state(0);
	ENGINE_cleanup();
	CONF_modules_unload(1);
	ERR_free_strings();
	EVP_cleanup();
	CRYPTO_cleanup_all_ex_data();
#endif

#ifdef WITH_SRV
	ares_library_cleanup();
#endif

#ifdef WIN32
	WSACleanup();
#endif
}
Пример #19
0
bool msl::encrypt_rsa(const void* plain,const size_t size,const std::string& key,std::string& cipher)
{
	bool success=true;
	ERR_load_crypto_strings();
	OpenSSL_add_all_algorithms();
	BIO* keybio=BIO_new_mem_buf((uint8_t*)key.c_str(),-1);

	if(keybio==nullptr)
		success=false;

	RSA* rsa=nullptr;

	if(success)
		rsa=PEM_read_bio_RSA_PUBKEY(keybio,&rsa,nullptr,nullptr);

	if(rsa==nullptr)
		success=false;

	if(size>(size_t)RSA_size(rsa)-RSA_PKCS1_OAEP_PADDING_SIZE)
		success=false;

	size_t temp_size=(size_t)-1;
	uint8_t* temp_data=new uint8_t[RSA_size(rsa)];

	if(success)
		temp_size=RSA_public_encrypt(size,(uint8_t*)plain,temp_data,rsa,RSA_PKCS1_OAEP_PADDING);

	if(success&&temp_size==(size_t)~0)
		success=false;

	if(success)
		cipher=std::string((char*)temp_data,temp_size);

	delete[] temp_data;
	BIO_free(keybio);
	RSA_free(rsa);
	ERR_free_strings();
	EVP_cleanup();
	ERR_remove_state(0);
	CRYPTO_cleanup_all_ex_data();
	return success;
}
Пример #20
0
/*
   Release SSL and free resources
   Will be automatically executed by 
   mysql_server_end() function

   SYNOPSIS
     my_ssl_end()
       void

   RETURN VALUES
     void
*/
void my_ssl_end()
{
  DBUG_ENTER("my_ssl_end");
  pthread_mutex_lock(&LOCK_ssl_config);
  if (my_ssl_initialized)
  {
    int i;

    if (LOCK_crypto)
    {
      CRYPTO_set_locking_callback(NULL);
      CRYPTO_set_id_callback(NULL);

      for (i=0; i < CRYPTO_num_locks(); i++)
        pthread_mutex_destroy(&LOCK_crypto[i]);

      my_free(LOCK_crypto);
      LOCK_crypto= NULL;
    }

    if (SSL_context)
    {
      SSL_CTX_free(SSL_context);
      SSL_context= FALSE;
    }
    if (mariadb_deinitialize_ssl)
    {
#if OPENSSL_VERSION_NUMBER < 0x10100000
      ERR_remove_state(0);
#endif
      EVP_cleanup();
      CRYPTO_cleanup_all_ex_data();
      ERR_free_strings();
      CONF_modules_free();
      CONF_modules_unload(1);
    }
    my_ssl_initialized= FALSE;
  }
  pthread_mutex_unlock(&LOCK_ssl_config);
  pthread_mutex_destroy(&LOCK_ssl_config);
  DBUG_VOID_RETURN;
}
Пример #21
0
void cleanup_openssl(global_data_t *global_data)
{
	SSL_CTX_free(global_data->ssl_ctx);
	CRYPTO_set_locking_callback(NULL);
	CRYPTO_set_id_callback(NULL);
	CRYPTO_set_dynlock_create_callback(NULL);
	CRYPTO_set_dynlock_destroy_callback(NULL);
	CRYPTO_set_dynlock_lock_callback(NULL);
	ERR_remove_state(0);
	ERR_free_strings();
	CONF_modules_unload(1);
	EVP_cleanup();
	CRYPTO_cleanup_all_ex_data();

	for (size_t i = 0; i < openssl_global_data.num_lock; i++)
		CHECK_ERROR(pthread_mutex_destroy, openssl_global_data.lock + i);

	free(openssl_global_data.lock);
	CHECK_ERROR(pthread_mutexattr_destroy, &openssl_global_data.lock_attr);
}
Пример #22
0
void	ssl_stream::close()
{
	socket_ = INVALID_SOCKET;
	if( ssl_ != NULL )
	{
		SSL_shutdown( ssl_ );  /* send SSL/TLS close_notify */
		SSL_free( ssl_ );
		ssl_ = NULL;
	}

	if( ssl_ctx_ != NULL )
	{
		SSL_CTX_free( ssl_ctx_ );
		ssl_ctx_ = NULL;

		ERR_free_strings();
		EVP_cleanup();
		CRYPTO_cleanup_all_ex_data();
	}
}
Пример #23
0
bool
SSLContext::Destroy(){
	if( !m_pssl_ctx ) 
		return false;
	SSL_CTX_free(m_pssl_ctx);
	m_pssl_ctx = NULL;

	CRYPTO_set_locking_callback			(NULL);
	CRYPTO_set_dynlock_create_callback	(NULL);
	CRYPTO_set_dynlock_lock_callback	(NULL);
	CRYPTO_set_dynlock_destroy_callback	(NULL);

    EVP_cleanup();
    CRYPTO_cleanup_all_ex_data	();
    ERR_remove_state			(0);
    ERR_free_strings			();

	// Destroy crypto locks.
	DestroyCryptoLocks			();
	return true;
	}
Пример #24
0
static void internal_idevice_deinit(void)
{
#ifdef HAVE_OPENSSL
	int i;
	if (mutex_buf) {
		CRYPTO_set_id_callback(NULL);
		CRYPTO_set_locking_callback(NULL);
		for (i = 0; i < CRYPTO_num_locks(); i++)
			mutex_destroy(&mutex_buf[i]);
		free(mutex_buf);
		mutex_buf = NULL;
	}

	/* Since there is no SSL_library_deinit... */
	EVP_cleanup();
	CRYPTO_cleanup_all_ex_data();
	sk_SSL_COMP_free(SSL_COMP_get_compression_methods());
#else
	gnutls_global_deinit();
#endif
}
Пример #25
0
void tls_shutdown(void)
{
    /*
     * FIXME: Don't free global tables, program or other libraries may use
     * openssl after libstrophe finalization. Maybe better leak some fixed
     * memory rather than cause random crashes of the main program.
     */
#if OPENSSL_VERSION_NUMBER < 0x10100000L
    ERR_free_strings();
    EVP_cleanup();
    CRYPTO_cleanup_all_ex_data();
#if OPENSSL_VERSION_NUMBER >= 0x10002000L
    SSL_COMP_free_compression_methods();
#endif
#if OPENSSL_VERSION_NUMBER < 0x10000000L
    ERR_remove_state(0);
#else
    ERR_remove_thread_state(NULL);
#endif
#endif
}
Пример #26
0
bool
SSLSocketServer::SSL_Destroy(){
	SSL_CTX_free(m_pssl_ctx);
	m_pssl_ctx = NULL;

	CRYPTO_set_locking_callback			(NULL);
	CRYPTO_set_dynlock_create_callback	(NULL);
	CRYPTO_set_dynlock_lock_callback	(NULL);
	CRYPTO_set_dynlock_destroy_callback	(NULL);

    EVP_cleanup();
    CRYPTO_cleanup_all_ex_data	();
    ERR_remove_state			(0);
    ERR_free_strings			();

	// Destroy crypto locks.
	DestroyCryptoLocks			();

	DeleteCriticalSection(&m_lock_connect_ex);
	return false;
	}
Пример #27
0
ENVELOP_API void env_release()
{
#ifdef WIN32
	if(0 == env_release_cert_list() && g_pub_key != NULL)
		EVP_PKEY_free(g_pub_key);
#else
	if(g_pub_key != NULL)
		EVP_PKEY_free(g_pub_key);
#endif

	if(g_prv_key != NULL)
		EVP_PKEY_free(g_prv_key);

	//释放Openssl
	do { 
		EVP_cleanup(); 
		CRYPTO_cleanup_all_ex_data(); 
		ERR_remove_state(0); 
		ERR_free_strings(); 
	} while(0);	
}
Пример #28
0
LWS_VISIBLE void
lws_ssl_destroy(struct lws_vhost *vhost)
{
	if (!lws_check_opt(vhost->context->options,
			   LWS_SERVER_OPTION_DO_SSL_GLOBAL_INIT))
		return;

	if (vhost->ssl_ctx)
		SSL_CTX_free(vhost->ssl_ctx);
	if (!vhost->user_supplied_ssl_ctx && vhost->ssl_client_ctx)
		SSL_CTX_free(vhost->ssl_client_ctx);

#if defined(LWS_WITH_MBEDTLS)
	if (vhost->x509_client_CA)
		X509_free(vhost->x509_client_CA);
#else
// after 1.1.0 no need
#if (OPENSSL_VERSION_NUMBER <  0x10100000)
// <= 1.0.1f = old api, 1.0.1g+ = new api
#if (OPENSSL_VERSION_NUMBER <= 0x1000106f) || defined(USE_WOLFSSL)
	ERR_remove_state(0);
#else
#if OPENSSL_VERSION_NUMBER >= 0x1010005f && \
    !defined(LIBRESSL_VERSION_NUMBER) && \
    !defined(OPENSSL_IS_BORINGSSL)
	ERR_remove_thread_state();
#else
	ERR_remove_thread_state(NULL);
#endif
#endif
	// after 1.1.0 no need
#if  (OPENSSL_VERSION_NUMBER >= 0x10002000) && (OPENSSL_VERSION_NUMBER <= 0x10100000)
	SSL_COMP_free_compression_methods();
#endif
	ERR_free_strings();
	EVP_cleanup();
	CRYPTO_cleanup_all_ex_data();
#endif
#endif
}
Пример #29
0
static bool boot_verify_compare_sha256(unsigned char *image_ptr,
		unsigned int image_size, unsigned char *signature_ptr, RSA *rsa)
{
	int ret = -1;
	bool auth = false;
	unsigned char *plain_text = NULL;
	unsigned int digest[8];

	plain_text = (unsigned char *)calloc(sizeof(char), SIGNATURE_SIZE);
	if (plain_text == NULL) {
		dprintf(CRITICAL, "boot_verifier: Calloc failed during verification\n");
		goto cleanup;
	}

	/* Calculate SHA256sum */
	image_find_digest(image_ptr, image_size, CRYPTO_AUTH_ALG_SHA256,
			(unsigned char *)&digest);

	/* Find digest from the image */
	ret = image_decrypt_signature_rsa(signature_ptr, plain_text, rsa);

	dprintf(SPEW, "boot_verifier: Return of RSA_public_decrypt = %d\n",
			ret);

	ret = verify_digest(plain_text, (unsigned char*)digest, SHA256_SIZE);
	if(ret == 0)
	{
		auth = true;
	}

cleanup:
	if (plain_text != NULL)
		free(plain_text);
	EVP_cleanup();
	CRYPTO_cleanup_all_ex_data();
	ERR_remove_thread_state(NULL);
	return auth;

}
Пример #30
0
/*
   Release SSL and free resources
   Will be automatically executed by 
   mysql_server_end() function

   SYNOPSIS
     my_ssl_end()
       void

   RETURN VALUES
     void
*/
void ma_tls_end()
{
  if (ma_tls_initialized)
  {
    pthread_mutex_lock(&LOCK_openssl_config);
#if OPENSSL_VERSION_NUMBER < 0x10100000L
    CRYPTO_set_locking_callback(NULL);
    CRYPTO_set_id_callback(NULL);
    {
      int i;
      for (i=0; i < CRYPTO_num_locks(); i++)
        pthread_mutex_destroy(&LOCK_crypto[i]);
    }
    ma_free((gptr)LOCK_crypto);
    LOCK_crypto= NULL;
#endif

    if (SSL_context)
    {
      SSL_CTX_free(SSL_context);
      SSL_context= NULL;
    }
    if (mariadb_deinitialize_ssl)
    {
#if OPENSSL_VERSION_NUMBER < 0x10100000L
      ERR_remove_state(0);
#endif
      EVP_cleanup();
      CRYPTO_cleanup_all_ex_data();
      ERR_free_strings();
      CONF_modules_free();
      CONF_modules_unload(1);
    }
    ma_tls_initialized= FALSE;
    pthread_mutex_unlock(&LOCK_openssl_config);
    pthread_mutex_destroy(&LOCK_openssl_config);
  }
  return;
}