Skip to content
Snippets Groups Projects
Commit f9739160 authored by Vladimir Davydov's avatar Vladimir Davydov Committed by Vladimir Davydov
Browse files

ssl: move OpenSSL library initialization code to separate file

We redefine ssl_init and ssl_free in the EE build, because we need to do
some extra work there. Currently, it's fine to duplicate the bulk of the
OpenSSL library initialization code between EE and CE repositories, but
with the introduction of OpenSSL 3.0 it's going to become more
complicated so duplicating would look bad. Let's move the common code to
ssl_init_impl() and ssl_free_impl() helper functions.

Needed for #6477

NO_DOC=refactoring
NO_TEST=refactoring
NO_CHANGELOG=refactoring
parent 9cc130f0
No related branches found
No related tags found
No related merge requests found
......@@ -39,6 +39,7 @@ set(core_sources
mp_interval.c
prbuf.c
clock_lowres.c
ssl_init.c
)
if(ENABLE_TUPLE_COMPRESSION)
......
......@@ -5,14 +5,11 @@
*/
#include "ssl.h"
#include <openssl/crypto.h>
#include <openssl/err.h>
#include <openssl/evp.h>
#include <openssl/ssl.h>
#include <stddef.h>
#include "diag.h"
#include "iostream.h"
#include "ssl_init.h"
#include "trivia/config.h"
#if defined(ENABLE_SSL)
......@@ -22,22 +19,13 @@
void
ssl_init(void)
{
#if OPENSSL_VERSION_NUMBER < 0x10100000L || defined(LIBRESSL_VERSION_NUMBER)
OpenSSL_add_all_digests();
OpenSSL_add_all_ciphers();
ERR_load_crypto_strings();
#else
OPENSSL_init_crypto(0, NULL);
OPENSSL_init_ssl(0, NULL);
#endif
ssl_init_impl();
}
void
ssl_free(void)
{
#ifdef OPENSSL_cleanup
OPENSSL_cleanup();
#endif
ssl_free_impl();
}
struct ssl_iostream_ctx *
......
/*
* SPDX-License-Identifier: BSD-2-Clause
*
* Copyright 2010-2022, Tarantool AUTHORS, please see AUTHORS file.
*/
#include "ssl_init.h"
#include <openssl/crypto.h>
#include <openssl/err.h>
#include <openssl/evp.h>
#include <openssl/ssl.h>
#include <stddef.h>
void
ssl_init_impl(void)
{
#if OPENSSL_VERSION_NUMBER < 0x10100000L || defined(LIBRESSL_VERSION_NUMBER)
OpenSSL_add_all_digests();
OpenSSL_add_all_ciphers();
ERR_load_crypto_strings();
#else
OPENSSL_init_crypto(0, NULL);
OPENSSL_init_ssl(0, NULL);
#endif
}
void
ssl_free_impl(void)
{
#ifdef OPENSSL_cleanup
OPENSSL_cleanup();
#endif
}
/*
* SPDX-License-Identifier: BSD-2-Clause
*
* Copyright 2010-2022, Tarantool AUTHORS, please see AUTHORS file.
*/
#pragma once
/**
* Initializes OpenSSL library. Internal method. Use ssl_init() instead.
*/
void
ssl_init_impl(void);
/**
* Frees OpenSSL library. Internal method. Use ssl_free() instead.
*/
void
ssl_free_impl(void);
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment