MySQL  8.0.27
Source Code Documentation
ssl_init_callback.h
Go to the documentation of this file.
1 /* Copyright (c) 2020, 2021, 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:
39  OptionalString() : value_(), empty_(true) {}
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:
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() = default;
71 };
72 
73 /**
74  Class to encasulate callbacks for init/reinit
75  for client server connection port
76 */
78  public:
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 
89  ~Ssl_init_callback_server_main() override = default;
90 
91  private:
93 };
94 
95 /**
96  Class to encasulate callbacks for init/reinit
97  for admin connection port
98 */
100  public:
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 
117  ~Ssl_init_callback_server_admin() override = default;
118 };
119 
122 
123 #endif // !SSL_INIT_CALLBACK_INCLUDED
ssl_artifacts_status
Definition: auth_common.h:883
helper class to deal with optionally empty strings
Definition: ssl_init_callback.h:37
~OptionalString()=default
OptionalString & assign(const char *s)
Definition: ssl_init_callback.h:45
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:99
bool warn_self_signed_ca() override
Definition: ssl_init_callback.cc:390
~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) override
Definition: ssl_init_callback.cc:369
bool provision_certs() override
Definition: ssl_init_callback.h:107
Class to encasulate callbacks for init/reinit for client server connection port.
Definition: ssl_init_callback.h:77
bool provision_certs() override
Definition: ssl_init_callback.cc:350
bool warn_self_signed_ca() override
Definition: ssl_init_callback.cc:362
~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) override
Definition: ssl_init_callback.cc:295
ssl_artifacts_status auto_detect_ssl()
Definition: ssl_init_callback.cc:311
Definition: ssl_init_callback.h:57
virtual bool warn_self_signed_ca()=0
virtual bool provision_certs()=0
virtual ~Ssl_init_callback()=default
virtual void read_parameters(OptionalString *ca, OptionalString *capath, OptionalString *version, OptionalString *cert, OptionalString *cipher, OptionalString *ciphersuites, OptionalString *key, OptionalString *crl, OptionalString *crl_path)=0
Dialog Client Authentication nullptr
Definition: dialog.cc:352
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:396
std::atomic_bool g_admin_ssl_configured
Ssl_init_callback_server_main server_main_callback
Definition: ssl_init_callback.cc:395