Webdar 1.0.0
Web user interface to libdar
ssl_context.hpp
1/*********************************************************************/
2// webdar - a web server and interface program to libdar
3// Copyright (C) 2013-2025 Denis Corbin
4//
5// This file is part of Webdar
6//
7// Webdar is free software: you can redistribute it and/or modify
8// it under the terms of the GNU General Public License as published by
9// the Free Software Foundation, either version 3 of the License, or
10// (at your option) any later version.
11//
12// Webdar is distributed in the hope that it will be useful,
13// but WITHOUT ANY WARRANTY; without even the implied warranty of
14// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15// GNU General Public License for more details.
16//
17// You should have received a copy of the GNU General Public License
18// along with Webdar. If not, see <http://www.gnu.org/licenses/>
19//
20//----
21// to contact the author: dar.linux@free.fr
22/*********************************************************************/
23
24#ifndef SSL_CONTEXT_HPP
25#define SSL_CONTEXT_HPP
26
27 // C system header files
28#include "my_config.h"
29extern "C"
30{
31#if HAVE_OPENSSL_SSL_H
32#include <openssl/ssl.h>
33#endif
34}
35
36 // C++ system header files
37#include <string>
38
39 // webdar headers
40#include "exceptions.hpp"
41
43
48
50{
51public:
52
54 ssl_context(const std::string & certificate, const std::string & privatekey);
55
57 ssl_context(const ssl_context & ref) = delete;
58 ssl_context(ssl_context && ref) noexcept = default;
59 ssl_context & operator = (const ssl_context & ref) = delete;
60 ssl_context & operator = (ssl_context && ref) noexcept = default;
61
63 ~ssl_context() { SSL_CTX_free(ctx); };
64
65 SSL_CTX & get_context() { return *ctx; };
66
67private:
68
69 SSL_CTX *ctx;
70
71 static bool initialized;
72 static void go_init_openssl();
73
74};
75
76#endif
manages an SSL context and initiate openssl library
Definition: ssl_context.hpp:50
ssl_context(const std::string &certificate, const std::string &privatekey)
constructor
Definition: ssl_context.cpp:38
ssl_context(const ssl_context &ref)=delete
forbidding copy, allowing move
~ssl_context()
destructor
Definition: ssl_context.hpp:63