MySQL 26.7.0
Source Code Documentation
ssl_acceptor_context_data.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_DATA_INCLUDED
25#define SSL_ACCEPTOR_CONTEXT_DATA_INCLUDED
26
27#include <string>
28
29#include "my_rcu_lock.h" /* MyRcuLock */
30#include "openssl/ossl_typ.h" /* SSL */
31#include "sql/ssl_init_callback.h" /* Ssl_init_callback */
32#include "violite.h" /* st_VioSSLFd, enum_ssl_init_error */
33
35class TLS_channel;
37
38/**
39 Properties exposed by Ssl Acceptor context
40
41 Note: Add new value before "last" and update
42 Ssl_acceptor_context_propert_type_names.
43*/
46 accepts,
63 tls_kex,
76 last
77};
78/**
79 Note: Add new value before "last" and update
80 Ssl_acceptor_context_propert_type_names.
81*/
82
83/**
84 Fetch a string representation of SSL acceptor context property
85
86 @param [in] property_type Property type
87
88 @returns name of the property
89*/
90std::string Ssl_ctx_property_name(
92
93/**
94 Increment operator for Ssl_acceptor_context_type
95 Used by iterator
96
97 @param [in,out] property_type Current position in Ssl_acceptor_context_type
98
99 @returns incremented value for property_type
100*/
103
104/**
105 Container of SSL Acceptor context data
106*/
108 public:
109 /**
110 Ctor
111
112 @param [in] channel Name of the channel
113 @param [in] callbacks TLS context initialization callbacks
114 to get values of various options and
115 perform validation
116 @param [in] report_ssl_error Report any SSL errors resulting from trying
117 to initialize the SSL_CTX to error log
118 @param [out] out_error An optional slot to return SSL_CTX
119 initialization error information
120 */
122 bool report_ssl_error = true,
123 enum enum_ssl_init_error *out_error = nullptr);
124
125 /** Destructor */
127
128 protected:
129 /* Disable copy/assignment */
132 delete;
133
134 /* Disable move constructs */
137
138 /**
139 Fetch given property from underlying TLS context
140
141 @param [in] property_type Property to be fetched
142
143 @returns Value of property for given context. Empty in case of failure.
144 */
145 std::string show_property(
146 Ssl_acceptor_context_property_type property_type) const;
147
148 /** TLS context validity */
149 bool have_ssl() const { return ssl_acceptor_fd_ != nullptr; }
150
151 /** Report that this channel can negotiate non-PQC sessions. */
153
154 /** Get channel name */
155 const char *channel_name() const { return channel_.c_str(); }
156
157 /** Get Acceptor context */
158 operator struct st_VioSSLFd *() { return ssl_acceptor_fd_; }
159
160 /** Get SSL handle */
161 operator SSL *() { return acceptor_; }
162
163 /** Get current CA */
164 const char *current_ca() const { return current_ca_.c_str(); }
165
166 /** Get current CA Path */
167 const char *current_capath() const { return current_capath_.c_str(); }
168
169 /** Get current Certificate */
170 const char *current_cert() const { return current_cert_.c_str(); }
171
172 /** Get current Key */
173 const char *current_key() const { return current_key_.c_str(); }
174
175 /** Get current CRL certificate */
176 const char *current_crl() const { return current_crl_.c_str(); }
177
178 /** Get current CRL Path */
179 const char *current_crlpath() const { return current_crlpath_.c_str(); }
180
181 /** Get current TLS version */
182 const char *current_version() const { return current_version_.c_str(); }
183
184 /** Get current TLSv1.2 ciphers */
185 const char *current_cipher() const { return current_cipher_.c_str(); }
186
187 /** Get current TLSv1.3 ciphers */
188 const char *current_ciphersuites() const {
190 }
191
192 const char *current_tls_kex() const { return current_tls_kex_.c_str(); }
193
194 private:
195 /** Channel name */
196 std::string channel_;
197
198 /** SSL_CTX barerer */
200
201 /**
202 An SSL for @ref ssl_acceptor_fd_ to allow access to parameters not in
203 SSL_CTX to be available even if the current connection is not
204 encrypted.
205 */
207
208 /**
209 Copies of the current effective values for quick return via the
210 status vars
211 */
219
220 /* F.R.I.E.N.D.S. */
222 friend class TLS_channel;
224};
225
226#endif // SSL_ACCEPTOR_CONTEXT_DATA_INCLUDED
TLS context access wrapper for ease of use.
Definition: ssl_acceptor_context_operator.h:106
helper class to deal with optionally empty strings
Definition: ssl_init_callback.h:50
const char * c_str() const
Definition: ssl_init_callback.h:57
TLS context access protector.
Definition: ssl_acceptor_context_operator.h:41
Container of SSL Acceptor context data.
Definition: ssl_acceptor_context_data.h:107
Ssl_acceptor_context_data operator=(const Ssl_acceptor_context_data &)=delete
OptionalString current_version_
Definition: ssl_acceptor_context_data.h:212
OptionalString current_key_
Definition: ssl_acceptor_context_data.h:213
~Ssl_acceptor_context_data()
Destructor.
Definition: ssl_acceptor_context_data.cc:395
std::string show_property(Ssl_acceptor_context_property_type property_type) const
Fetch given property from underlying TLS context.
Definition: ssl_acceptor_context_data.cc:400
const char * current_cert() const
Get current Certificate.
Definition: ssl_acceptor_context_data.h:170
const char * channel_name() const
Get channel name.
Definition: ssl_acceptor_context_data.h:155
bool current_tls_force_pqc_
Definition: ssl_acceptor_context_data.h:217
OptionalString current_tls_kex_
Definition: ssl_acceptor_context_data.h:214
void report_tls_channel_without_force_pqc() const
Report that this channel can negotiate non-PQC sessions.
Definition: ssl_acceptor_context_data.cc:391
Ssl_acceptor_context_data operator=(Ssl_acceptor_context_data &&)=delete
OptionalString current_capath_
Definition: ssl_acceptor_context_data.h:212
bool current_tls_use_pqc_sign_
Definition: ssl_acceptor_context_data.h:218
const char * current_version() const
Get current TLS version.
Definition: ssl_acceptor_context_data.h:182
OptionalString current_crl_
Definition: ssl_acceptor_context_data.h:213
std::string channel_
Channel name.
Definition: ssl_acceptor_context_data.h:196
const char * current_key() const
Get current Key.
Definition: ssl_acceptor_context_data.h:173
Ssl_acceptor_context_data(Ssl_acceptor_context_data &&)=delete
const char * current_cipher() const
Get current TLSv1.2 ciphers.
Definition: ssl_acceptor_context_data.h:185
bool current_tls_session_cache_mode_
Definition: ssl_acceptor_context_data.h:216
const char * current_ciphersuites() const
Get current TLSv1.3 ciphers.
Definition: ssl_acceptor_context_data.h:188
const char * current_tls_kex() const
Definition: ssl_acceptor_context_data.h:192
OptionalString current_ciphersuites_
Definition: ssl_acceptor_context_data.h:213
OptionalString current_crlpath_
Definition: ssl_acceptor_context_data.h:214
OptionalString current_cipher_
Definition: ssl_acceptor_context_data.h:213
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
const char * current_capath() const
Get current CA Path.
Definition: ssl_acceptor_context_data.h:167
struct st_VioSSLFd * ssl_acceptor_fd_
SSL_CTX barerer.
Definition: ssl_acceptor_context_data.h:199
const char * current_ca() const
Get current CA.
Definition: ssl_acceptor_context_data.h:164
Ssl_acceptor_context_data(std::string channel, Ssl_init_callback *callbacks, bool report_ssl_error=true, enum enum_ssl_init_error *out_error=nullptr)
Ctor.
Definition: ssl_acceptor_context_data.cc:296
const char * current_crl() const
Get current CRL certificate.
Definition: ssl_acceptor_context_data.h:176
OptionalString current_ca_
Copies of the current effective values for quick return via the status vars.
Definition: ssl_acceptor_context_data.h:212
OptionalString current_cert_
Definition: ssl_acceptor_context_data.h:212
bool have_ssl() const
TLS context validity.
Definition: ssl_acceptor_context_data.h:149
long current_tls_session_cache_timeout_
Definition: ssl_acceptor_context_data.h:215
const char * current_crlpath() const
Get current CRL Path.
Definition: ssl_acceptor_context_data.h:179
Ssl_acceptor_context_data(const Ssl_acceptor_context_data &)=delete
Definition: ssl_init_callback.h:70
TLS context manager.
Definition: ssl_acceptor_context_operator.h:60
Ssl_acceptor_context_property_type
Properties exposed by Ssl Acceptor context.
Definition: ssl_acceptor_context_data.h:44
std::string Ssl_ctx_property_name(Ssl_acceptor_context_property_type property_type)
Note: Add new value before "last" and update Ssl_acceptor_context_propert_type_names.
Definition: ssl_acceptor_context_data.cc:271
Ssl_acceptor_context_property_type & operator++(Ssl_acceptor_context_property_type &property_type)
Increment operator for Ssl_acceptor_context_type Used by iterator.
Definition: ssl_acceptor_context_data.cc:286
Definition: task.h:427
Definition: violite.h:260
Vio Lite.
enum_ssl_init_error
Definition: violite.h:236