4#include "Stroika/Foundation/StroikaPreComp.h"
6#if qStroika_HasComponent_OpenSSL
7#include <openssl/evp.h>
8#include <openssl/ssl.h>
11#include "Stroika/Foundation/Cryptography/Providers/OpenSSL/Certificate.h"
13#include "Stroika/Foundation/Cryptography/Providers/OpenSSL/PrivateKey.h"
15#include "Stroika/Foundation/Execution/Exceptions.h"
18#include "ServerContext.h"
22using namespace Stroika::Foundation::Cryptography;
23using namespace Stroika::Foundation::Cryptography::PKI;
24using namespace Stroika::Foundation::Cryptography::Providers;
25using namespace Stroika::Foundation::Cryptography::Providers::OpenSSL;
26using namespace Stroika::Foundation::Debug;
28using Memory::MakeSharedPtr;
33#if qStroika_HasComponent_OpenSSL
35 using OpenSSL::ServerContext::Options;
37 OpenSSL::ServerContext::LibRepType fCtx_;
39 Rep_ (
const Options& o)
40 : fCtx_{::SSL_CTX_new (o.fMethod)}
42 RequireNotNull (get<Cryptography::PKI::Certificate::Ptr> (o.fCertificate));
43 OpenSSL::Exception::ThrowLastErrorIfFailed (::SSL_CTX_use_certificate (
44 fCtx_.get (), OpenSSL::Certificate::Ptr{get<Cryptography::PKI::Certificate::Ptr> (o.fCertificate)}.Get_X509 ()));
46 OpenSSL::Exception::ThrowLastErrorIfFailed (
47 ::SSL_CTX_use_PrivateKey (fCtx_.get (), OpenSSL::PrivateKey::Ptr{get<PKI::PrivateKey::Ptr> (o.fCertificate)}.Get_EVP_PKEY ()));
49 virtual SSL_CTX* Get_SSL_CTX ()
const override
56auto OpenSSL::ServerContext::New (
const Options& o) -> Ptr
58 return MakeSharedPtr<Rep_> (o);
#define RequireNotNull(p)
conditional_t< qStroika_Foundation_Memory_PreferBlockAllocation and andTrueCheck, BlockAllocationUseHelper< T >, Common::Empty > UseBlockAllocationIfAppropriate
Use this to enable block allocation for a particular class. Beware of subclassing.