Stroika Library 3.0d16
 
Loading...
Searching...
No Matches
Providers/OpenSSL/ServerContext.h
1/*
2 * Copyright(c) Sophist Solutions, Inc. 1990-2025. All rights reserved
3 */
4#ifndef _Stroika_Foundation_Cryptography_OpenSSL_ServerContext_h_
5#define _Stroika_Foundation_Cryptography_OpenSSL_ServerContext_h_ 1
6
7#include "Stroika/Foundation/StroikaPreComp.h"
8
9#include <memory>
10
11#if qStroika_HasComponent_OpenSSL
12#include <openssl/ssl.h>
13#endif
14
15#include "Stroika/Foundation/Common/Common.h"
16#include "Stroika/Foundation/Cryptography/SSL/ServerContext.h"
17
18namespace Stroika::Foundation::Cryptography::Providers::OpenSSL::ServerContext {
19
20#if qStroika_HasComponent_OpenSSL
21
22 /**
23 */
24 struct LibRepType : unique_ptr<::SSL_CTX, decltype (&::SSL_CTX_free)> {
25 using inherited = unique_ptr<::SSL_CTX, decltype (&::SSL_CTX_free)>;
26
27 LibRepType (nullptr_t);
28 LibRepType (LibRepType&&) = default;
29 LibRepType (SSL_CTX* p);
30 };
31
32 /**
33 */
34 struct IRep : Cryptography::SSL::ServerContext::IRep {
35 virtual SSL_CTX* Get_SSL_CTX () const = 0;
36 };
37
38 /**
39 */
40 struct Ptr : shared_ptr<IRep> {
41 using inherited = shared_ptr<IRep>;
42 /**
43 * (1) normal shared_ptr constructors supported
44 * (2) copy from const shared_ptr<IRep>&, to clarify overload avoid ambiguity
45 * (3) shared_ptr<PKI::Certificate::IRep>& - a dynamic_pointer_cast - which only works - which throws if not the right type
46 */
47 using inherited::inherited;
48 Ptr (const shared_ptr<IRep>& p);
49 Ptr (const shared_ptr<SSL::ServerContext::IRep>& p);
50 };
51
52 struct Options : SSL::ServerContext::Options {
53 const SSL_METHOD* fMethod{::TLS_server_method ()};
54 };
55
56 /**
57 */
58 Ptr New (const Options& o);
59#endif
60
61}
62
63/*
64 ********************************************************************************
65 ***************************** Implementation Details ***************************
66 ********************************************************************************
67 */
68#include "ServerContext.inl"
69
70#endif /*_Stroika_Foundation_Cryptography_OpenSSL_ServerContext_h_*/