MySQL 8.3.0
Source Code Documentation
ssl_acceptor_context_data.h
Go to the documentation of this file.
1/* Copyright (c) 2020, 2023, 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_ACCEPTOR_CONTEXT_DATA_INCLUDED
24#define SSL_ACCEPTOR_CONTEXT_DATA_INCLUDED
25
26#include <string>
27
28#include "my_rcu_lock.h" /* MyRcuLock */
29#include "openssl/ossl_typ.h" /* SSL */
30#include "sql/ssl_init_callback.h" /* Ssl_init_callback */
31#include "violite.h" /* st_VioSSLFd, enum_ssl_init_error */
32
34class TLS_channel;
36
37/**
38 Properties exposed by Ssl Acceptor context
39
40 Note: Add new value before "last" and update
41 Ssl_acceptor_context_propert_type_names.
42*/
45 accepts,
72 last
73};
74/**
75 Note: Add new value before "last" and update
76 Ssl_acceptor_context_propert_type_names.
77*/
78
79/**
80 Fetch a string representation of SSL acceptor context property
81
82 @param [in] property_type Property type
83
84 @returns name of the property
85*/
86std::string Ssl_ctx_property_name(
88
89/**
90 Increment operator for Ssl_acceptor_context_type
91 Used by iterator
92
93 @param [in,out] property_type Current position in Ssl_acceptor_context_type
94
95 @returns incremented value for property_type
96*/
99
100/**
101 Container of SSL Acceptor context data
102*/
104 public:
105 /**
106 Ctor
107
108 @param [in] channel Name of the channel
109 @param [in] use_ssl_arg Don't bother at all to try and construct
110 an SSL_CTX and just make an empty
111 SslAcceptorContext. Used to pass the
112 --ssl/--admin-ssl options at startup.
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 */
121 Ssl_acceptor_context_data(std::string channel, bool use_ssl_arg,
122 Ssl_init_callback *callbacks,
123 bool report_ssl_error = true,
124 enum enum_ssl_init_error *out_error = nullptr);
125
126 /** Destructor */
128
129 protected:
130 /* Disable copy/assignment */
133 delete;
134
135 /* Disable move constructs */
138
139 /**
140 Fetch given property from underlying TLS context
141
142 @param [in] property_type Property to be fetched
143
144 @returns Value of property for given context. Empty in case of failure.
145 */
146 std::string show_property(
147 Ssl_acceptor_context_property_type property_type) const;
148
149 /** TLS context validity */
150 bool have_ssl() const { return ssl_acceptor_fd_ != nullptr; }
151
152 /** Get channel name */
153 const char *channel_name() const { return channel_.c_str(); }
154
155 /** Get Acceptor context */
156 operator struct st_VioSSLFd *() { return ssl_acceptor_fd_; }
157
158 /** Get SSL handle */
159 operator SSL *() { return acceptor_; }
160
161 /** Get current CA */
162 const char *current_ca() const { return current_ca_.c_str(); }
163
164 /** Get current CA Path */
165 const char *current_capath() const { return current_capath_.c_str(); }
166
167 /** Get current Certificate */
168 const char *current_cert() const { return current_cert_.c_str(); }
169
170 /** Get current Key */
171 const char *current_key() const { return current_key_.c_str(); }
172
173 /** Get current CRL certificate */
174 const char *current_crl() const { return current_crl_.c_str(); }
175
176 /** Get current CRL Path */
177 const char *current_crlpath() const { return current_crlpath_.c_str(); }
178
179 /** Get current TLS version */
180 const char *current_version() const { return current_version_.c_str(); }
181
182 /** Get current TLSv1.2 ciphers */
183 const char *current_cipher() const { return current_cipher_.c_str(); }
184
185 /** Get current TLSv1.3 ciphers */
186 const char *current_ciphersuites() const {
188 }
189
190 private:
191 /** Channel name */
192 std::string channel_;
193
194 /** SSL_CTX barerer */
196
197 /**
198 An SSL for @ref ssl_acceptor_fd_ to allow access to parameters not in
199 SSL_CTX to be available even if the current connection is not
200 encrypted.
201 */
203
204 /**
205 Copies of the current effective values for quick return via the
206 status vars
207 */
213
214 /* F.R.I.E.N.D.S. */
216 friend class TLS_channel;
218};
219
220#endif // SSL_ACCEPTOR_CONTEXT_DATA_INCLUDED
TLS context access wrapper for ease of use.
Definition: ssl_acceptor_context_operator.h:104
helper class to deal with optionally empty strings
Definition: ssl_init_callback.h:38
const char * c_str() const
Definition: ssl_init_callback.h:45
TLS context access protector.
Definition: ssl_acceptor_context_operator.h:40
Container of SSL Acceptor context data.
Definition: ssl_acceptor_context_data.h:103
Ssl_acceptor_context_data operator=(const Ssl_acceptor_context_data &)=delete
OptionalString current_version_
Definition: ssl_acceptor_context_data.h:208
OptionalString current_key_
Definition: ssl_acceptor_context_data.h:209
~Ssl_acceptor_context_data()
Destructor.
Definition: ssl_acceptor_context_data.cc:351
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:356
const char * current_cert() const
Get current Certificate.
Definition: ssl_acceptor_context_data.h:168
const char * channel_name() const
Get channel name.
Definition: ssl_acceptor_context_data.h:153
Ssl_acceptor_context_data operator=(Ssl_acceptor_context_data &&)=delete
OptionalString current_capath_
Definition: ssl_acceptor_context_data.h:208
const char * current_version() const
Get current TLS version.
Definition: ssl_acceptor_context_data.h:180
OptionalString current_crl_
Definition: ssl_acceptor_context_data.h:209
std::string channel_
Channel name.
Definition: ssl_acceptor_context_data.h:192
const char * current_key() const
Get current Key.
Definition: ssl_acceptor_context_data.h:171
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:183
bool current_tls_session_cache_mode_
Definition: ssl_acceptor_context_data.h:212
const char * current_ciphersuites() const
Get current TLSv1.3 ciphers.
Definition: ssl_acceptor_context_data.h:186
OptionalString current_ciphersuites_
Definition: ssl_acceptor_context_data.h:209
OptionalString current_crlpath_
Definition: ssl_acceptor_context_data.h:210
OptionalString current_cipher_
Definition: ssl_acceptor_context_data.h:209
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:202
const char * current_capath() const
Get current CA Path.
Definition: ssl_acceptor_context_data.h:165
struct st_VioSSLFd * ssl_acceptor_fd_
SSL_CTX barerer.
Definition: ssl_acceptor_context_data.h:195
const char * current_ca() const
Get current CA.
Definition: ssl_acceptor_context_data.h:162
const char * current_crl() const
Get current CRL certificate.
Definition: ssl_acceptor_context_data.h:174
Ssl_acceptor_context_data(std::string channel, bool use_ssl_arg, Ssl_init_callback *callbacks, bool report_ssl_error=true, enum enum_ssl_init_error *out_error=nullptr)
Ctor.
Definition: ssl_acceptor_context_data.cc:282
OptionalString current_ca_
Copies of the current effective values for quick return via the status vars.
Definition: ssl_acceptor_context_data.h:208
OptionalString current_cert_
Definition: ssl_acceptor_context_data.h:208
bool have_ssl() const
TLS context validity.
Definition: ssl_acceptor_context_data.h:150
long current_tls_session_cache_timeout_
Definition: ssl_acceptor_context_data.h:211
const char * current_crlpath() const
Get current CRL Path.
Definition: ssl_acceptor_context_data.h:177
Ssl_acceptor_context_data(const Ssl_acceptor_context_data &)=delete
Definition: ssl_init_callback.h:58
TLS context manager.
Definition: ssl_acceptor_context_operator.h:59
Ssl_acceptor_context_property_type
Properties exposed by Ssl Acceptor context.
Definition: ssl_acceptor_context_data.h:43
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:266
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:272
Definition: task.h:426
Definition: violite.h:255
Vio Lite.
enum_ssl_init_error
Definition: violite.h:235