MySQL 26.7.0
Source Code Documentation
ssl_acceptor_context_operator.h
Go to the documentation of this file.
1/* Copyright (c) 2020, 2026, 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 designed to work 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 either included with
13 the program or referenced in the documentation.
14
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License, version 2.0, for more details.
19
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
23
24#ifndef SSL_ACCEPTOR_CONTEXT_OPERATOR
25#define SSL_ACCEPTOR_CONTEXT_OPERATOR
26
27#include <my_rcu_lock.h> /* MyRcuLock */
28#include "sql/ssl_acceptor_context_data.h" /** Ssl_acceptor_context_data */
29
30/* Types of supported contexts */
35};
36
38class TLS_channel;
39
40/** TLS context access protector */
42 protected:
46
48
50
51 /* F.R.I.E.N.D.S. */
53 friend class TLS_channel;
54};
55
58
59/** TLS context manager */
61 public:
62 /**
63 Initialize the single instance of the acceptor
64
65 @param [out] out Object initialized by the function
66 @param [in] channel Name of the channel
67 @param [in] callbacks Handle to the initialization callback object
68 @param [in] db_init Whether database is being initialized or not
69
70 @returns Initialization status
71 @retval true failure to init
72 @retval false initialized ok
73*/
75 const std::string &channel,
76 Ssl_init_callback *callbacks, bool db_init);
77
78 /**
79 De-initialize the single instance of the acceptor
80
81 @param [in] container TLS acceptor context object
82 */
84 /**
85 Re-initialize the single instance of the acceptor
86
87 @param [in,out] container TLS acceptor context object
88 @param [in] channel Name of the channel
89 @param [in] callbacks Handle to the initialization callback object
90 @param [out] error SSL Error information
91 @param [in] force Activate the SSL settings even if this will lead
92 to disabling SSL
93 @param [in] warn_without_force_pqc
94 Report when the TLS context does not require
95 post-quantum key exchange groups
96 */
98 std::string channel, Ssl_init_callback *callbacks,
99 enum enum_ssl_init_error *error, bool force,
100 bool warn_without_force_pqc);
101};
102
104
105/** TLS context access wrapper for ease of use */
107 public:
109 : read_lock_(context->lock_) {}
111
112 /** Access protected @ref Ssl_acceptor_context_data */
113 operator const Ssl_acceptor_context_data *() {
115 return c;
116 }
117
118 /**
119 Access to the SSL_CTX from the protected @ref Ssl_acceptor_context_data
120 */
121 operator SSL_CTX *() {
123 return c->ssl_acceptor_fd_->ssl_context;
124 }
125
126 /**
127 Access to the SSL from the protected @ref Ssl_acceptor_context_data
128 */
129 operator SSL *() {
131 return c->acceptor_;
132 }
133
134 /**
135 Access to st_VioSSLFd from the protected @ref Ssl_acceptor_context_data
136 */
137 operator struct st_VioSSLFd *() {
139 return c->ssl_acceptor_fd_;
140 }
141
142 /**
143 Fetch given property from underlying TLS context
144
145 @param [in] property_type Property to be fetched
146
147 @returns Value of property for given context. Empty in case of failure.
148 */
149 std::string show_property(Ssl_acceptor_context_property_type property_type);
150
151 /**
152 Fetch channel name
153
154 @returns Name of underlying channel
155 */
156 std::string channel_name();
157
158 /**
159 TLS context validity
160
161 @returns Validity of TLS context
162 @retval true Valid
163 @retval false Invalid
164 */
165 bool have_ssl();
166
167 private:
168 /** Read lock over TLS context */
170};
171
172bool have_ssl();
173
174#endif // SSL_ACCEPTOR_CONTEXT_OPERATOR
app_data_ptr new_data(u_int n, char *val, cons_type consensus)
TLS context access wrapper for ease of use.
Definition: ssl_acceptor_context_operator.h:106
Ssl_acceptor_context_data_lock::ReadLock read_lock_
Read lock over TLS context.
Definition: ssl_acceptor_context_operator.h:169
Lock_and_access_ssl_acceptor_context(Ssl_acceptor_context_container *context)
Definition: ssl_acceptor_context_operator.h:108
bool have_ssl()
TLS context validity.
Definition: ssl_acceptor_context_operator.cc:130
std::string show_property(Ssl_acceptor_context_property_type property_type)
Fetch given property from underlying TLS context.
Definition: ssl_acceptor_context_operator.cc:119
std::string channel_name()
Fetch channel name.
Definition: ssl_acceptor_context_operator.cc:125
High level read API for readers.
Definition: my_rcu_lock.h:113
A class that implements a limited version of the Read-Copy-Update lock pattern.
Definition: my_rcu_lock.h:80
TLS context access protector.
Definition: ssl_acceptor_context_operator.h:41
void switch_data(Ssl_acceptor_context_data *new_data)
Definition: ssl_acceptor_context_operator.cc:48
Ssl_acceptor_context_data_lock * lock_
Definition: ssl_acceptor_context_operator.h:49
~Ssl_acceptor_context_container()
Definition: ssl_acceptor_context_operator.cc:43
Ssl_acceptor_context_container(Ssl_acceptor_context_data *data)
Definition: ssl_acceptor_context_operator.cc:37
Container of SSL Acceptor context data.
Definition: ssl_acceptor_context_data.h:107
SSL * acceptor_
An SSL for ssl_acceptor_fd_ to allow access to parameters not in SSL_CTX to be available even if the ...
Definition: ssl_acceptor_context_data.h:206
struct st_VioSSLFd * ssl_acceptor_fd_
SSL_CTX barerer.
Definition: ssl_acceptor_context_data.h:199
Definition: ssl_init_callback.h:70
TLS context manager.
Definition: ssl_acceptor_context_operator.h:60
static void singleton_deinit(Ssl_acceptor_context_container *container)
De-initialize the single instance of the acceptor.
Definition: ssl_acceptor_context_operator.cc:97
static void singleton_flush(Ssl_acceptor_context_container *container, std::string channel, Ssl_init_callback *callbacks, enum enum_ssl_init_error *error, bool force, bool warn_without_force_pqc)
Re-initialize the single instance of the acceptor.
Definition: ssl_acceptor_context_operator.cc:102
static bool singleton_init(Ssl_acceptor_context_container **out, const std::string &channel, Ssl_init_callback *callbacks, bool db_init)
Initialize the single instance of the acceptor.
Definition: ssl_acceptor_context_operator.cc:53
Definition: atomics_array.h:39
Ssl_acceptor_context_property_type
Properties exposed by Ssl Acceptor context.
Definition: ssl_acceptor_context_data.h:44
bool have_ssl()
Definition: ssl_acceptor_context_operator.cc:135
Ssl_acceptor_context_type
Ssl_acceptor_context_data.
Definition: ssl_acceptor_context_operator.h:31
Ssl_acceptor_context_container * mysql_main
Definition: ssl_acceptor_context_operator.cc:34
Ssl_acceptor_context_container * mysql_admin
Definition: ssl_acceptor_context_operator.cc:35
Definition: task.h:427
Definition: violite.h:260
SSL_CTX * ssl_context
Definition: violite.h:261
enum_ssl_init_error
Definition: violite.h:236