MySQL 8.0.39
Source Code Documentation
mysql_ssl_rsa_setup.cc File Reference
#include "my_config.h"
#include <mysql_version.h>
#include <stdint.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <algorithm>
#include <array>
#include <cstdio>
#include <cstdlib>
#include <fstream>
#include <iostream>
#include <sstream>
#include <string>
#include "client/client_priv.h"
#include "client/logger.h"
#include "client/path.h"
#include "my_alloc.h"
#include "my_compiler.h"
#include "my_dbug.h"
#include "my_default.h"
#include "my_dir.h"
#include "my_getopt.h"
#include "my_inttypes.h"
#include "my_io.h"
#include "my_macros.h"
#include "my_sys.h"
#include "mysql/service_mysql_alloc.h"
#include "print_version.h"
#include "welcome_copyright_notice.h"
#include <pwd.h>
#include <openssl/ssl.h>

Classes

class  RSA_priv
 
class  RSA_pub
 
class  X509_key
 
class  X509v3_ext_writer
 
class  X509_cert
 

Macros

#define MAX_PATH_LEN    (FN_REFLEN - strlen(FN_DIRSEP) - cert_files[SERVER_CERT].length() - 1)
 
#define MAX_SUFFIX_LEN   17
 

Typedefs

typedef string Sql_string_t
 

Enumerations

enum  certs {
  CA_CERT = 0 , CA_KEY , CA_REQ , SERVER_CERT ,
  SERVER_KEY , SERVER_REQ , CLIENT_CERT , CLIENT_KEY ,
  CLIENT_REQ , PRIVATE_KEY , PUBLIC_KEY , OPENSSL_RND
}
 
enum  extfiles { CAV3_EXT = 0 , CERTV3_EXT }
 

Functions

static Sql_string_t create_string (const char *ptr)
 The string class will break if constructed with a NULL pointer. More...
 
int security_level (void)
 
static int execute_command (const Sql_string_t &command, const Sql_string_t &error_message)
 
static int set_file_pair_permission (const Sql_string_t &priv, const Sql_string_t &pub)
 
static bool file_exists (const Sql_string_t &filename)
 
static int remove_file (const Sql_string_t &filename, bool report_error=true)
 
static void free_resources ()
 
static void usage (void)
 
static bool my_arguments_get_one_option (int optid, const struct my_option *, char *)
 
static bool is_not_alnum_underscore (char c)
 
static bool check_suffix ()
 
int main (int argc, char *argv[])
 

Variables

constexpr const std::array rsa_key_sizes {2048, 2048, 2048, 3072, 7680, 15360}
 
Sql_string_t cert_files []
 
Sql_string_t ext_files []
 
Log info (cout, "NOTE")
 
Log error (cerr, "ERROR")
 
char ** defaults_argv = nullptr
 
static char * opt_datadir = nullptr
 
static char default_data_dir [] = MYSQL_DATADIR
 
static char * opt_suffix = nullptr
 
static char default_suffix [] = MYSQL_SERVER_VERSION
 
static char * opt_userid = nullptr
 
struct passwd * user_info = nullptr
 
Path dir_string
 
Sql_string_t suffix_string
 
bool opt_verbose
 
static const char * load_default_groups []
 
static struct my_option my_options []
 

Macro Definition Documentation

◆ MAX_PATH_LEN

#define MAX_PATH_LEN    (FN_REFLEN - strlen(FN_DIRSEP) - cert_files[SERVER_CERT].length() - 1)

◆ MAX_SUFFIX_LEN

#define MAX_SUFFIX_LEN   17

Typedef Documentation

◆ Sql_string_t

typedef string Sql_string_t

Enumeration Type Documentation

◆ certs

enum certs
Enumerator
CA_CERT 
CA_KEY 
CA_REQ 
SERVER_CERT 
SERVER_KEY 
SERVER_REQ 
CLIENT_CERT 
CLIENT_KEY 
CLIENT_REQ 
PRIVATE_KEY 
PUBLIC_KEY 
OPENSSL_RND 

◆ extfiles

enum extfiles
Enumerator
CAV3_EXT 
CERTV3_EXT 

Function Documentation

◆ check_suffix()

static bool check_suffix ( )
static

◆ create_string()

static Sql_string_t create_string ( const char *  ptr)
static

The string class will break if constructed with a NULL pointer.

This wrapper provides a systematic protection when importing char pointers.

◆ execute_command()

static int execute_command ( const Sql_string_t command,
const Sql_string_t error_message 
)
static

◆ file_exists()

static bool file_exists ( const Sql_string_t filename)
static

◆ free_resources()

static void free_resources ( )
static

◆ is_not_alnum_underscore()

static bool is_not_alnum_underscore ( char  c)
inlinestatic

◆ main()

int main ( int  argc,
char *  argv[] 
)

◆ my_arguments_get_one_option()

static bool my_arguments_get_one_option ( int  optid,
const struct my_option ,
char *   
)
static

◆ remove_file()

static int remove_file ( const Sql_string_t filename,
bool  report_error = true 
)
static

◆ security_level()

int security_level ( void  )

◆ set_file_pair_permission()

static int set_file_pair_permission ( const Sql_string_t priv,
const Sql_string_t pub 
)
static

◆ usage()

static void usage ( void  )
static

Variable Documentation

◆ cert_files

Sql_string_t cert_files[]
Initial value:
= {
create_string("ca.pem"), create_string("ca-key.pem"),
create_string("ca-req.pem"), create_string("server-cert.pem"),
create_string("server-key.pem"), create_string("server-req.pem"),
create_string("client-cert.pem"), create_string("client-key.pem"),
create_string("client-req.pem"), create_string("private_key.pem"),
create_string("public_key.pem"), create_string(".rnd")}
static Sql_string_t create_string(const char *ptr)
The string class will break if constructed with a NULL pointer.
Definition: mysql_ssl_rsa_setup.cc:193

◆ default_data_dir

char default_data_dir[] = MYSQL_DATADIR
static

◆ default_suffix

char default_suffix[] = MYSQL_SERVER_VERSION
static

◆ defaults_argv

char** defaults_argv = nullptr

◆ dir_string

Path dir_string

◆ error

Log error(cerr, "ERROR") ( cerr  ,
"ERROR"   
)

◆ ext_files

Sql_string_t ext_files[]
Initial value:
= {create_string("cav3.ext"),
create_string("certv3.ext")}

◆ info

Log info(cout, "NOTE") ( cout  ,
"NOTE"   
)

◆ load_default_groups

const char* load_default_groups[]
static
Initial value:
= {"mysql_ssl_rsa_setup", "mysqld",
nullptr}

◆ my_options

struct my_option my_options[]
static
Initial value:
= {
{"help", '?', "Display this help and exit.", nullptr, nullptr, nullptr,
GET_NO_ARG, NO_ARG, 0, 0, 0, nullptr, 0, nullptr},
{"verbose", 'v', "Be more verbose when running program", &opt_verbose,
nullptr, nullptr, GET_BOOL, NO_ARG, false, 0, 0, nullptr, 0, nullptr},
{"version", 'V', "Print program version and exit", nullptr, nullptr,
nullptr, GET_NO_ARG, NO_ARG, 0, 0, 0, nullptr, 0, nullptr},
{"datadir", 'd', "Directory to store generated files.", &opt_datadir,
(longlong)&default_data_dir, 0, 0, nullptr, 0, nullptr},
{"suffix", 's', "Suffix to be added in certificate subject line",
(longlong)&default_suffix, 0, 0, nullptr, 0, nullptr},
{"uid", 0, "The effective user id to be used for file permission",
nullptr, 0, nullptr},
{nullptr, 0, nullptr, nullptr, nullptr, nullptr, GET_NO_ARG, NO_ARG, 0, 0,
0, nullptr, 0, nullptr}}
#define GET_NO_ARG
Definition: my_getopt.h:44
@ REQUIRED_ARG
Definition: my_getopt.h:81
@ NO_ARG
Definition: my_getopt.h:81
#define GET_STR_ALLOC
Definition: my_getopt.h:53
#define GET_BOOL
Definition: my_getopt.h:45
long long int longlong
Definition: my_inttypes.h:55
static char * opt_userid
Definition: mysql_ssl_rsa_setup.cc:124
static char * opt_datadir
Definition: mysql_ssl_rsa_setup.cc:119
static char default_data_dir[]
Definition: mysql_ssl_rsa_setup.cc:120
static char * opt_suffix
Definition: mysql_ssl_rsa_setup.cc:121
static char default_suffix[]
Definition: mysql_ssl_rsa_setup.cc:122
bool opt_verbose
Definition: mysql_ssl_rsa_setup.cc:129

◆ opt_datadir

char* opt_datadir = nullptr
static

◆ opt_suffix

char* opt_suffix = nullptr
static

◆ opt_userid

char* opt_userid = nullptr
static

◆ opt_verbose

bool opt_verbose

◆ rsa_key_sizes

constexpr const std::array rsa_key_sizes {2048, 2048, 2048, 3072, 7680, 15360}
constexpr

◆ suffix_string

Sql_string_t suffix_string

◆ user_info

struct passwd* user_info = nullptr