MySQL 8.4.2
Source Code Documentation
certificate_handler.h
Go to the documentation of this file.
1/*
2 Copyright (c) 2020, 2024, Oracle and/or its affiliates.
3
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License, version 2.0,
6 as published by the Free Software Foundation.
7
8 This program is designed to work with certain software (including
9 but not limited to OpenSSL) that is licensed under separate terms,
10 as designated in a particular file or component or in included license
11 documentation. The authors of MySQL hereby grant you an additional
12 permission to link the program and your derivative works with the
13 separately licensed software that they have either included with
14 the program or referenced in the documentation.
15
16 This program is distributed in the hope that it will be useful,
17 but WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 GNU General Public License for more details.
20
21 You should have received a copy of the GNU General Public License
22 along with this program; if not, write to the Free Software
23 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
24*/
25
26#ifndef ROUTER_CERTIFICATE_HANDLER_INCLUDED
27#define ROUTER_CERTIFICATE_HANDLER_INCLUDED
28
30
33
35 public:
36 /**
37 * Handle X.509 Router and CA keys and certificates.
38 *
39 * @param[in] ca_key_path Path to CA key file.
40 * @param[in] ca_cert_path Path to CA certificate file.
41 * @param[in] router_key_path Path to Router key file.
42 * @param[in] router_cert_path Path to Router certificate file.
43 */
45 mysql_harness::Path ca_cert_path,
46 mysql_harness::Path router_key_path,
47 mysql_harness::Path router_cert_path)
48 : ca_key_path_{std::move(ca_key_path)},
49 ca_cert_path_{std::move(ca_cert_path)},
50 router_key_path_{std::move(router_key_path)},
51 router_cert_path_{std::move(router_cert_path)} {}
52
53 /**
54 * Check if none of the Router and CA key/certificate files exists.
55 *
56 * @retval true No certificate file exists.
57 * @retval false Some certificate files exists.
58 */
59 bool no_cert_files_exists() const;
60
61 /**
62 * Check if Router key and certificate files exists.
63 *
64 * @retval true Both Router key and certificate files exists.
65 * @retval false Router certificate and/or key file is missing.
66 */
67 bool router_cert_files_exists() const;
68
69 /**
70 * Create Router and CA key and certificate files at configured paths.
71 *
72 * @return std::error_code on failure
73 */
75
76 private:
82 const std::string k_CA_CN{"MySQL_Router_Auto_Generated_CA_Certificate"};
83 const std::string k_router_CN{
84 "MySQL_Router_Auto_Generated_Router_Certificate"};
85};
86
87#endif // ROUTER_CERTIFICATE_HANDLER_INCLUDED
Definition: certificate_generator.h:105
Definition: certificate_handler.h:34
CertificateGenerator cert_gen_
Definition: certificate_handler.h:77
mysql_harness::Path router_key_path_
Definition: certificate_handler.h:80
mysql_harness::Path ca_key_path_
Definition: certificate_handler.h:78
CertificateHandler(mysql_harness::Path ca_key_path, mysql_harness::Path ca_cert_path, mysql_harness::Path router_key_path, mysql_harness::Path router_cert_path)
Handle X.509 Router and CA keys and certificates.
Definition: certificate_handler.h:44
mysql_harness::Path ca_cert_path_
Definition: certificate_handler.h:79
mysql_harness::Path router_cert_path_
Definition: certificate_handler.h:81
Class representing a path in a file system.
Definition: filesystem.h:63
Definition: expected.h:284
static mysql_service_status_t create(const char *service_names[], reference_caching_channel *out_channel) noexcept
Definition: component.cc:45
Definition: gcs_xcom_synode.h:64
#define ROUTER_LIB_EXPORT
Definition: router_export.h:15