MySQL 8.0.30
Source Code Documentation
ssl_init_callback.h
Go to the documentation of this file.
1/* Copyright (c) 2020, 2022, Oracle and/or its affiliates.
2
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License, version 2.0,
5 as published by the Free Software Foundation.
6
7 This program is also distributed with certain software (including
8 but not limited to OpenSSL) that is licensed under separate terms,
9 as designated in a particular file or component or in included license
10 documentation. The authors of MySQL hereby grant you an additional
11 permission to link the program and your derivative works with the
12 separately licensed software that they have included with MySQL.
13
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License, version 2.0, for more details.
18
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
22
23#ifndef SSL_INIT_CALLBACK_INCLUDED
24#define SSL_INIT_CALLBACK_INCLUDED
25
26#include <atomic>
27#include <string>
28
29#include <sql/auth/auth_common.h> /* ssl_artifacts_status */
30
31extern std::atomic_bool g_admin_ssl_configured;
32
33extern std::string mysql_main_channel;
34extern std::string mysql_admin_channel;
35
36/** helper class to deal with optionally empty strings */
38 public:
40 OptionalString(const char *s) : value_(s ? s : ""), empty_(!s) {}
41 ~OptionalString() = default;
42 OptionalString(const OptionalString &) = default;
43
44 const char *c_str() const { return empty_ ? nullptr : value_.c_str(); }
45 OptionalString &assign(const char *s) {
46 value_.assign(s ? s : "");
47 empty_ = !s;
48 return *this;
49 }
50
51 private:
52 std::string value_;
53 bool empty_;
54};
55
56/* Class to encasulate callbacks for init/reinit */
58 public:
61 OptionalString *cipher,
62 OptionalString *ciphersuites,
64 OptionalString *crl_path,
66 long *session_cache_timeout) = 0;
67
68 virtual bool provision_certs() = 0;
69
70 virtual bool warn_self_signed_ca() = 0;
71
72 virtual ~Ssl_init_callback() = default;
73};
74
75/**
76 Class to encasulate callbacks for init/reinit
77 for client server connection port
78*/
80 public:
83 OptionalString *cipher, OptionalString *ciphersuites,
85 OptionalString *crl_path, bool *session_cache_mode,
86 long *session_cache_timeout) override;
87
88 bool provision_certs() override;
89
90 bool warn_self_signed_ca() override;
91
92 ~Ssl_init_callback_server_main() override = default;
93
94 private:
96};
97
98/**
99 Class to encasulate callbacks for init/reinit
100 for admin connection port
101*/
103 public:
106 OptionalString *cipher, OptionalString *ciphersuites,
108 OptionalString *crl_path, bool *session_cache_mode,
109 long *session_cache_timeout) override;
110
111 bool provision_certs() override {
112 /*
113 No automatic provisioning. Always return
114 success to fallback to system variables.
115 */
116 return false;
117 }
118
119 bool warn_self_signed_ca() override;
120
122};
123
126
127/**
128 Helper method to validate values of --tls-version and --admin-tls-version
129*/
130bool validate_tls_version(const char *val);
131#endif // !SSL_INIT_CALLBACK_INCLUDED
ssl_artifacts_status
Definition: auth_common.h:892
helper class to deal with optionally empty strings
Definition: ssl_init_callback.h:37
OptionalString & assign(const char *s)
Definition: ssl_init_callback.h:45
~OptionalString()=default
OptionalString(const char *s)
Definition: ssl_init_callback.h:40
std::string value_
Definition: ssl_init_callback.h:52
OptionalString(const OptionalString &)=default
bool empty_
Definition: ssl_init_callback.h:53
OptionalString()
Definition: ssl_init_callback.h:39
const char * c_str() const
Definition: ssl_init_callback.h:44
Class to encasulate callbacks for init/reinit for admin connection port.
Definition: ssl_init_callback.h:102
bool warn_self_signed_ca() override
Definition: ssl_init_callback.cc:446
~Ssl_init_callback_server_admin() override=default
void read_parameters(OptionalString *ca, OptionalString *capath, OptionalString *version, OptionalString *cert, OptionalString *cipher, OptionalString *ciphersuites, OptionalString *key, OptionalString *crl, OptionalString *crl_path, bool *session_cache_mode, long *session_cache_timeout) override
Definition: ssl_init_callback.cc:421
bool provision_certs() override
Definition: ssl_init_callback.h:111
Class to encasulate callbacks for init/reinit for client server connection port.
Definition: ssl_init_callback.h:79
bool provision_certs() override
Definition: ssl_init_callback.cc:402
bool warn_self_signed_ca() override
Definition: ssl_init_callback.cc:414
~Ssl_init_callback_server_main() override=default
void read_parameters(OptionalString *ca, OptionalString *capath, OptionalString *version, OptionalString *cert, OptionalString *cipher, OptionalString *ciphersuites, OptionalString *key, OptionalString *crl, OptionalString *crl_path, bool *session_cache_mode, long *session_cache_timeout) override
Definition: ssl_init_callback.cc:343
ssl_artifacts_status auto_detect_ssl()
Definition: ssl_init_callback.cc:363
Definition: ssl_init_callback.h:57
virtual void read_parameters(OptionalString *ca, OptionalString *capath, OptionalString *version, OptionalString *cert, OptionalString *cipher, OptionalString *ciphersuites, OptionalString *key, OptionalString *crl, OptionalString *crl_path, bool *session_cache_mode, long *session_cache_timeout)=0
virtual bool warn_self_signed_ca()=0
virtual bool provision_certs()=0
virtual ~Ssl_init_callback()=default
Fido Client Authentication nullptr
Definition: fido_client_plugin.cc:221
required string key
Definition: replication_asynchronous_connection_failover.proto:59
required uint64 version
Definition: replication_group_member_actions.proto:40
std::string mysql_admin_channel
std::string mysql_main_channel
Ssl_init_callback_server_admin server_admin_callback
Definition: ssl_init_callback.cc:452
bool validate_tls_version(const char *val)
Helper method to validate values of –tls-version and –admin-tls-version.
Definition: ssl_init_callback.cc:69
std::atomic_bool g_admin_ssl_configured
Ssl_init_callback_server_main server_main_callback
Definition: ssl_init_callback.cc:451