Merge MakeAsioSslContext() into SetupSslContext()

This commit is contained in:
Alexander A. Klimov 2024-07-04 10:26:12 +02:00
parent fa08e90630
commit 86ba556615
2 changed files with 5 additions and 23 deletions

View File

@ -195,27 +195,6 @@ static void InitSslContext(const Shared<TlsContext>::Ptr& context, const String&
} }
} }
/**
* Initializes an SSL context using the specified certificates.
*
* @param pubkey The public key.
* @param privkey The matching private key.
* @param cakey CA certificate chain file.
* @returns An SSL context.
*/
Shared<TlsContext>::Ptr MakeAsioSslContext(const String& pubkey, const String& privkey, const String& cakey)
{
namespace ssl = boost::asio::ssl;
InitializeOpenSSL();
auto context (Shared<TlsContext>::Make(TlsContext::tls));
InitSslContext(context, pubkey, privkey, cakey);
return context;
}
/** /**
* Set the cipher list to the specified SSL context. * Set the cipher list to the specified SSL context.
* @param context The ssl context. * @param context The ssl context.
@ -286,8 +265,12 @@ Shared<TlsContext>::Ptr SetupSslContext(const String& certPath, const String& ke
Shared<TlsContext>::Ptr context; Shared<TlsContext>::Ptr context;
InitializeOpenSSL();
try { try {
context = MakeAsioSslContext(certPath, keyPath, caPath); context = Shared<TlsContext>::Make(TlsContext::tls);
InitSslContext(context, certPath, keyPath, caPath);
} catch (const std::exception&) { } catch (const std::exception&) {
BOOST_THROW_EXCEPTION(ScriptError("Cannot make SSL context for cert path: '" BOOST_THROW_EXCEPTION(ScriptError("Cannot make SSL context for cert path: '"
+ certPath + "' key path: '" + keyPath + "' ca path: '" + caPath + "'.", std::move(di))); + certPath + "' key path: '" + keyPath + "' ca path: '" + caPath + "'.", std::move(di)));

View File

@ -44,7 +44,6 @@ void InitializeOpenSSL();
String GetOpenSSLVersion(); String GetOpenSSLVersion();
Shared<TlsContext>::Ptr MakeAsioSslContext(const String& pubkey = String(), const String& privkey = String(), const String& cakey = String());
void AddCRLToSSLContext(const Shared<TlsContext>::Ptr& context, const String& crlPath); void AddCRLToSSLContext(const Shared<TlsContext>::Ptr& context, const String& crlPath);
void AddCRLToSSLContext(X509_STORE *x509_store, const String& crlPath); void AddCRLToSSLContext(X509_STORE *x509_store, const String& crlPath);
void SetCipherListToSSLContext(const Shared<TlsContext>::Ptr& context, const String& cipherList); void SetCipherListToSSLContext(const Shared<TlsContext>::Ptr& context, const String& cipherList);