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"
17#include "ServerContext.h"
21using namespace Stroika::Foundation::Cryptography;
22using namespace Stroika::Foundation::Cryptography::PKI;
23using namespace Stroika::Foundation::Cryptography::Providers;
24using namespace Stroika::Foundation::Cryptography::Providers::OpenSSL;
25using namespace Stroika::Foundation::Debug;
30#if qStroika_HasComponent_OpenSSL
32 using OpenSSL::ServerContext::Options;
33 struct Rep_ : OpenSSL::ServerContext::IRep {
34 OpenSSL::ServerContext::LibRepType fCtx_;
36 Rep_ (
const Options& o)
37 : fCtx_{::SSL_CTX_new (o.fMethod)}
39 RequireNotNull (get<Cryptography::PKI::Certificate::Ptr> (o.fCertificate));
40 OpenSSL::Exception::ThrowLastErrorIfFailed (::SSL_CTX_use_certificate (
41 fCtx_.get (), OpenSSL::Certificate::Ptr{get<Cryptography::PKI::Certificate::Ptr> (o.fCertificate)}.Get_X509 ()));
43 OpenSSL::Exception::ThrowLastErrorIfFailed (
44 ::SSL_CTX_use_PrivateKey (fCtx_.get (), OpenSSL::PrivateKey::Ptr{get<PKI::PrivateKey::Ptr> (o.fCertificate)}.Get_EVP_PKEY ()));
46 virtual SSL_CTX* Get_SSL_CTX ()
const override
53auto OpenSSL::ServerContext::New (
const Options& o) -> Ptr
55 return make_shared<Rep_> (o);
#define RequireNotNull(p)