MySQL  8.0.22
Source Code Documentation
ssl_init_callback.h
Go to the documentation of this file.
1 /* Copyright (c) 2020, 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 
31 extern std::atomic_bool g_admin_ssl_configured;
32 
33 extern std::string mysql_main_channel;
34 extern 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) {}
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:
59  virtual void read_parameters(OptionalString *ca, OptionalString *capath,
61  OptionalString *cipher,
62  OptionalString *ciphersuites,
64  OptionalString *crl_path) = 0;
65 
66  virtual bool provision_certs() = 0;
67 
68  virtual bool warn_self_signed_ca() = 0;
69 
70  virtual ~Ssl_init_callback() {}
71 };
72 
73 /**
74  Class to encasulate callbacks for init/reinit
75  for client server connection port
76 */
78  public:
79  void read_parameters(OptionalString *ca, OptionalString *capath,
81  OptionalString *cipher, OptionalString *ciphersuites,
83  OptionalString *crl_path) override;
84 
85  bool provision_certs() override;
86 
87  bool warn_self_signed_ca() override;
88 
90 
91  private:
92  ssl_artifacts_status auto_detect_ssl();
93 };
94 
95 /**
96  Class to encasulate callbacks for init/reinit
97  for admin connection port
98 */
100  public:
101  void read_parameters(OptionalString *ca, OptionalString *capath,
103  OptionalString *cipher, OptionalString *ciphersuites,
105  OptionalString *crl_path) override;
106 
107  bool provision_certs() override {
108  /*
109  No automatic provisioning. Always return
110  success to fallback to system variables.
111  */
112  return false;
113  }
114 
115  bool warn_self_signed_ca() override;
116 
118 };
119 
122 
123 #endif // !SSL_INIT_CALLBACK_INCLUDED
~OptionalString()
Definition: ssl_init_callback.h:41
Definition: ssl_init_callback.h:57
~Ssl_init_callback_server_main() override
Definition: ssl_init_callback.h:89
Ssl_init_callback_server_main server_main_callback
Definition: ssl_init_callback.cc:395
Class to encasulate callbacks for init/reinit for admin connection port.
Definition: ssl_init_callback.h:99
bool provision_certs() override
Definition: ssl_init_callback.h:107
~Ssl_init_callback_server_admin() override
Definition: ssl_init_callback.h:117
virtual ~Ssl_init_callback()
Definition: ssl_init_callback.h:70
bool empty_
Definition: ssl_init_callback.h:53
OptionalString & assign(const char *s)
Definition: ssl_init_callback.h:45
const char * c_str() const
Definition: ssl_init_callback.h:44
#define final(a, b, c)
Definition: hash.c:109
#define true
Definition: config_static.h:44
helper class to deal with optionally empty strings
Definition: ssl_init_callback.h:37
const string version("\ersion\)
OptionalString()
Definition: ssl_init_callback.h:39
OptionalString(const char *s)
Definition: ssl_init_callback.h:40
static const char * key
Definition: suite_stubs.c:14
Class to encasulate callbacks for init/reinit for client server connection port.
Definition: ssl_init_callback.h:77
std::string mysql_main_channel
Ssl_init_callback_server_admin server_admin_callback
Definition: ssl_init_callback.cc:396
std::string value_
Definition: ssl_init_callback.h:52
std::atomic_bool g_admin_ssl_configured
std::string mysql_admin_channel
ssl_artifacts_status
Definition: auth_common.h:880
Dialog Client Authentication nullptr
Definition: dialog.cc:353