1
0
mirror of https://github.com/lammertb/libhttp.git synced 2025-08-09 03:22:45 +03:00
Files
libhttp/src/httplib_uninitialize_ssl.c
2016-12-10 16:56:54 +01:00

68 lines
2.2 KiB
C

/*
* Copyright (c) 2016 Lammert Bies
* Copyright (c) 2013-2016 the Civetweb developers
* Copyright (c) 2004-2013 Sergey Lyubka
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#include "libhttp-private.h"
/*
* void XX_httplib_unitialize_ssl( struct mg_context *ctx );
*
* The function XX_httplib_unititialize_ssl() is used to properly stop the SSL
* subsystem.
*/
#if !defined(NO_SSL)
void XX_httplib_uninitialize_ssl( struct mg_context *ctx ) {
int i;
(void)ctx;
if (XX_httplib_atomic_dec(&XX_httplib_cryptolib_users) == 0) {
/* Shutdown according to
* https://wiki.openssl.org/index.php/Library_Initialization#Cleanup
* http://stackoverflow.com/questions/29845527/how-to-properly-uninitialize-openssl
*/
CRYPTO_set_locking_callback(NULL);
CRYPTO_set_id_callback(NULL);
ENGINE_cleanup();
CONF_modules_unload(1);
ERR_free_strings();
EVP_cleanup();
CRYPTO_cleanup_all_ex_data();
ERR_remove_state(0);
for (i = 0; i < CRYPTO_num_locks(); i++) {
pthread_mutex_destroy(&XX_httplib_ssl_mutexes[i]);
}
XX_httplib_free(XX_httplib_ssl_mutexes);
XX_httplib_ssl_mutexes = NULL;
}
} /* XX_httplib_unitialize_ssl */
#endif /* !NO_SSL */