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
22
23namespace openvpn::NSCert {
30
31inline 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
41inline 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
const Option * get_ptr(const std::string &name) const
Definition options.hpp:1186
std::string get_optional(const size_t index, const size_t max_len) const
Definition options.hpp:194
Type ns_cert_type(const std::string &ct)
Definition nscert.hpp:31