OpenVPN 3 Core Library
Loading...
Searching...
No Matches
nscert.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
// Parse the ns-cert-type option.
13
14
#ifndef OPENVPN_SSL_NSCERT_H
15
#define OPENVPN_SSL_NSCERT_H
16
17
#include <string>
18
19
#include <
openvpn/common/size.hpp
>
20
#include <
openvpn/common/exception.hpp
>
21
#include <
openvpn/common/options.hpp
>
22
23
namespace
openvpn::NSCert
{
24
enum
Type
25
{
26
NONE
,
27
CLIENT
,
28
SERVER
29
};
30
31
inline
Type
ns_cert_type
(
const
std::string &ct)
32
{
33
if
(ct ==
"server"
)
34
return
SERVER
;
35
else
if
(ct ==
"client"
)
36
return
CLIENT
;
37
else
38
throw
option_error(ERR_INVALID_OPTION_CRYPTO,
"ns-cert-type must be 'client' or 'server'"
);
39
}
40
41
inline
Type
ns_cert_type
(
const
OptionList
&opt,
const
std::string &relay_prefix)
42
{
43
const
Option
*o = opt.
get_ptr
(relay_prefix +
"ns-cert-type"
);
44
if
(o)
45
{
46
const
std::string ct = o->
get_optional
(1, 16);
47
return
ns_cert_type
(ct);
48
}
49
return
NONE
;
50
}
51
}
// namespace openvpn::NSCert
52
53
#endif
openvpn::OptionList
Definition
options.hpp:517
openvpn::OptionList::get_ptr
const Option * get_ptr(const std::string &name) const
Definition
options.hpp:1186
openvpn::Option
Definition
options.hpp:62
openvpn::Option::get_optional
std::string get_optional(const size_t index, const size_t max_len) const
Definition
options.hpp:194
exception.hpp
openvpn::NSCert
Definition
nscert.hpp:23
openvpn::NSCert::Type
Type
Definition
nscert.hpp:25
openvpn::NSCert::CLIENT
@ CLIENT
Definition
nscert.hpp:27
openvpn::NSCert::SERVER
@ SERVER
Definition
nscert.hpp:28
openvpn::NSCert::NONE
@ NONE
Definition
nscert.hpp:26
openvpn::NSCert::ns_cert_type
Type ns_cert_type(const std::string &ct)
Definition
nscert.hpp:31
options.hpp
size.hpp
openvpn
ssl
nscert.hpp
Generated by
1.9.8