OpenVPN 3 Core Library
Loading...
Searching...
No Matches
engine.hpp
Go to the documentation of this file.
1// OpenVPN -- An application to securely tunnel IP networks
2// over a single port, with support for SSL/TLS-based
3// session authentication and key exchange,
4// packet encryption, packet authentication, and
5// packet compression.
6//
7// Copyright (C) 2012- OpenVPN Inc.
8//
9// SPDX-License-Identifier: MPL-2.0 OR AGPL-3.0-only WITH openvpn3-openssl-exception
10//
11
12// Method to set up a particular OpenSSL engine type
13
14#ifndef OPENVPN_OPENSSL_UTIL_ENGINE_H
15#define OPENVPN_OPENSSL_UTIL_ENGINE_H
16
17#include <string>
18
19#if (OPENSSL_VERSION_NUMBER >= 0x30000000L)
20#define OPENSSL_NO_ENGINE
21#endif
22
23#ifndef OPENSSL_NO_ENGINE
24#include <openssl/engine.h>
25#endif
26
29
30namespace openvpn {
31
32OPENVPN_EXCEPTION(openssl_engine_error);
33
34inline void openssl_setup_engine(const std::string &engine)
35{
36#ifndef OPENSSL_NO_ENGINE
37 ENGINE_load_builtin_engines();
38
39 if (engine == "auto")
40 {
41 ENGINE_register_all_complete();
42 return;
43 }
44
45 ENGINE *e = ENGINE_by_id(engine.c_str());
46 if (!e)
47 throw openssl_engine_error();
48 if (!ENGINE_set_default(e, ENGINE_METHOD_ALL))
49 throw openssl_engine_error();
50#endif
51}
52
53} // namespace openvpn
54
55#endif // OPENVPN_OPENSSL_UTIL_ENGINE_H
#define OPENVPN_EXCEPTION(C)
Support deferred server-side state creation when client connects.
Definition ovpncli.cpp:95
void openssl_setup_engine(const std::string &engine)
Definition engine.hpp:34