NDB 集群中 TLS 密钥和证书的管理实现为可执行工具程序 ndb_sign_keys,该程序通常位于 MySQL 的 bin 目录中。该程序执行的功能包括创建、签署以及注销密钥和证书,并且通常按以下方式工作:Management of TLS keys and certificates in implemented in NDB
Cluster as the executable utility program
ndb_sign_keys, which can normally be found in
the MySQL bin directory. The program
performs such functions as creating, signing, and retiring keys
and certificates, and normally works as follows:
ndb_sign_keys 连接到 ndb_mgmd 并获取集群的配置。ndb_sign_keys connects to ndb_mgmd and fetches the cluster' configuration.
对于每个配置在本地机器上运行的集群节点,ndb_sign_keys 会找到节点的私钥并进行签署,从而创建一个有效的节点证书。For each cluster node that is configured to run on the local machine, ndb_sign_keys finds the node' private key and sign it, creating an active node certificate.
以下列出了可以由 ndb_sign_keys 执行的一些附加任务:Some additional tasks that can be performed by ndb_sign_keys are listed here:
从 config.ini 文件获取配置信息,而不是从正在运行的 ndb_mgmd 获取Obtaining configuration information from a config.ini file rather than a running ndb_mgmd
如果尚不存在,则创建集群的证书颁发机构(CA)Creating the cluster' certificate authority (CA) if it does not yet exist
创建私钥Creating private keys
将密钥和证书保存为待定状态,而非激活状态Saving keys and certificates as pending rather than active
使用本节后面描述的命令行选项为指定的单个节点签署密钥Signing the key for a single node as specified using command-line options described later in this section
请求位于远程主机的 CA 为本地密钥签署Requesting a CA located on a remote host to sign a local key
可以与 ndb_sign_keys 一起使用的选项显示在下表中。表格后面还有更多说明。Options that can be used with ndb_sign_keys are shown in the following table. Additional descriptions follow the table.
命令行格式Command-Line Format --bind-host=host类型Type 字符串String 默认值Default Value mgmd, api创建一个证书,并绑定到指定的节点类型主机名列表,这些节点类型应来自
(mgmd,db,api)集合。Create a certificate bound to a hostname list of node types that should have certificate hostname bindings, from the set(mgmd,db,api).命令行格式Command-Line Format --bound-hostname=hostname类型Type 字符串String 默认值Default Value [none][none]创建一个绑定到传递给此选项的主机名的证书。Create a certificate bound to the hostname passed to this option.
命令行格式Command-Line Format --CA-cert=name类型Type 文件名File name 默认值Default Value NDB-Cluster-cert使用传递给此选项的名称作为 CA 证书文件。Use the name passed to this option for the CA Certificate file.
命令行格式Command-Line Format --CA-days=#类型Type 整数Integer 默认值Default Value 1461最小值Minimum Value -1最大值Maximum Value 2147483647将证书的有效期设置为此天数。默认值相当于 4 年加 1 天。
-1表示证书永不过期。Set the lifetime of the certificate to this many days. The default is equivalent to 4 years plus 1 day.-1means the certificate never expires.此选项在 NDB 8.4.1 中添加。This option was added in NDB 8.4.1.
命令行格式Command-Line Format --CA-key=name类型Type 文件名File name 默认值Default Value NDB-Cluster-private-key使用传递给此选项的名称作为 CA 私钥文件名。Use the name passed to this option for the CA private key file.
命令行格式Command-Line Format --CA-ordinal=name类型Type 字符串String 默认值Default Value [none][none]有效值Valid Values FirstSecond设置序号 CA 名称;默认值为
First对于--create-CA,以及Second对于--rotate-CA。CA 证书中的通用名称为 “MySQL NDB ClusterordinalCertificate”,其中ordinal是传递给此选项的序号名称。Set the ordinal CA name; defaults toFirstfor--create-CAandSecondfor--rotate-CA. The Common Name in the CA certificate is “MySQL NDB ClusterordinalCertificate”, whereordinalis the ordinal name passed to this option.命令行格式Command-Line Format --CA-search-path=name类型Type 文件名File name 默认值Default Value [none][none]指定用于搜索 CA 文件的目录列表。在 Unix 平台上,目录名称用冒号 (
:) 分隔;在 Windows 系统上,使用分号 (;) 作为分隔符。目录引用可以是相对路径或绝对路径;它可以包含一个或多个环境变量,每个变量以美元符号 ($) 开头,并在使用前进行展开。Specify a list of directories to search for a CA file. On Unix platforms, the directory names are separated by colons (:); on Windows systems, the semicolon character (;) is used as the separator. A directory reference may be relative or absolute; it may contain one or more environment variables, each denoted by a prefixed dollar sign ($), and expanded prior to use.搜索从最左边的命名目录开始,从左到右进行,直到找到文件为止。空字符串表示空搜索路径,这会导致所有搜索失败。由单个点(
.)组成的字符串表示搜索路径仅限于当前工作目录。Searching begins with the leftmost named directory and proceeds from left to right until a file is found. An empty string denotes an empty search path, which causes all searches to fail. A string consisting of a single dot (.) indicates that the search path is limited to the current working directory.如果未提供搜索路径,将使用编译时的默认值。此值取决于所使用的平台:在 Windows 上,为
$HOMEPATH\ndb-tls;在其他平台(包括 Linux)上,为$HOME/ndb-tls。可以通过在编译 NDB Cluster 时使用-DWITH_NDB_TLS_SEARCH_PATH来覆盖此默认值。If no search path is supplied, the compiled-in default value is used. This value depends on the platform used: On Windows, this is$HOMEPATH\ndb-tls; on other platforms (including Linux), it is$HOME/ndb-tls. This default can be overridden by compiling NDB Cluster using-DWITH_NDB_TLS_SEARCH_PATH.命令行格式Command-Line Format --CA-tool=name类型Type 文件名File name 默认值Default Value [none][none]指定一个可执行的辅助工具,包括其路径。Designate an executable helper tool, including the path.
命令行格式Command-Line Format --check检查证书到期日期。Check certificate expiry dates.
命令行格式Command-Line Format --config-file=file禁用者Disabled by no-config类型Type 文件名File name 默认值Default Value [none][none]提供集群配置文件的路径(通常是
config.ini)。Supply the path to the cluster configuration file (usuallyconfig.ini).命令行格式Command-Line Format --connect-retries=#类型Type 整数Integer 默认值Default Value 12最小值Minimum Value -1最大值Maximum Value 12设置 ndb_sign_keys 尝试连接集群的次数。如果使用
-1,程序会持续尝试连接,直到成功或被迫停止。Set the number of times that ndb_sign_keys attempts to connect to the cluster. If you use-1, the program keeps trying to connect until it succeeds or is forced to stop.命令行格式Command-Line Format --connect-retry-delay=#类型Type 整数Integer 默认值Default Value 5最小值Minimum Value 0最大值Maximum Value 5设置在连接尝试失败后,ndb_sign_keys 在再次尝试之前等待的秒数,最多尝试次数由
--connect-retries决定。Set the number of seconds after a failed connection attempt which ndb_sign_keys waits before trying again, up to the number of times determined by--connect-retries.命令行格式Command-Line Format --create-CA创建 CA 密钥和证书。Create the CA key and certificate.
命令行格式Command-Line Format --create-key创建或替换私钥。Create or replace private keys.
命令行格式Command-Line Format --curve=name类型Type 字符串String 默认值Default Value P-256使用指定的曲线加密节点密钥。Use the named curve for encrypting node keys.
命令行格式Command-Line Format --defaults-extra-file=path--defaults-extra-file=path类型Type 字符串String 默认值Default Value [none][none]在读取全局文件后读取此选项文件。Read this option file after the global files are read.
命令行格式Command-Line Format --defaults-file=path类型Type 字符串String 默认值Default Value [none][none]只读取此选项文件。Read this option file only.
命令行格式Command-Line Format --defaults-group-suffix=string类型Type 字符串String 默认值Default Value [none][none]不仅读取通常的选项组,还读取具有通常名称并带有
string后缀的组。Read not only the usual option groups, but also groups with the usual names and a suffix ofstring.命令行格式Command-Line Format --duration=#类型Type 整数Integer 默认值Default Value 0最小值Minimum Value -500000最大值Maximum Value 0单位Unit 秒seconds 设置证书或签名请求的有效期,单位为秒。Set the lifetime of certificates or signing requests, in seconds.
命令行格式Command-Line Format --help--help打印帮助文本并退出。Print help text and exit.
命令行格式Command-Line Format --keys-to-dir=dirname类型Type 目录名称Directory name 默认值Default Value [none][none]指定私钥的输出目录(仅限私钥);为此,它会覆盖为
--to-dir设置的任何值。Specify output directory for private keys (only); for this purpose, it overrides any value set for--to-dir.命令行格式Command-Line Format --login-path=path类型Type 字符串String 默认值Default Value [none][none]从登录文件读取此路径。Read this path from the login file.
命令行格式Command-Line Format --ndb-connectstring=connection_string类型Type 字符串String 默认值Default Value [none][none]设置用于连接 ndb_mgmd 的连接字符串,使用语法
[nodeid=。如果设置了此选项,它将覆盖id;][host=]hostname[:port]NDB_CONNECTSTRING(如果有)中设置的值,以及my.cnf文件中配置的任何值。Set the connection string to use for connecting to ndb_mgmd, using the syntax[nodeid=. If this option is set, it overrides the value set forid;][host=]hostname[:port]NDB_CONNECTSTRING(if any), as well as any value set in amy.cnf. file.命令行格式Command-Line Format --ndb-mgm-tls=level类型Type 枚举Enumeration 默认值Default Value relaxedrelaxed有效值Valid Values relaxedrelaxedstrictstrict设置 ndb_mgm 客户端所需的 TLS 支持级别;可选择
relaxed或strict。relaxed(默认)表示尝试建立 TLS 连接,但不要求成功;strict表示必须通过 TLS 才能连接。Sets the level of TLS support required for the ndb_mgm client; one ofrelaxedorstrict.relaxed(the default) means that a TLS connection is attempted, but success is not required;strictmeans that TLS is required to connect.命令行格式Command-Line Format --ndb-tls-search-path=list类型Type 路径名Path name 默认值(Unix)Default Value (Unix) $HOME/ndb-tls$HOME/ndb-tls默认值(Windows)Default Value (Windows) $HOMEDIR/ndb-tls指定包含 TLS 密钥和证书的目录列表。Specify a list of directories containing TLS keys and certificates.
有关语法,请参阅
--CA-search-path选项的描述。For syntax, see the description of the--CA-search-pathoption.命令行格式Command-Line Format --no-config不获取集群配置;基于提供的选项(包括未指定选项的默认值)创建单个证书。Do not obtain the cluster configuration; create a single certificate based on the options supplied (including defaults for those not specified).
命令行格式Command-Line Format --no-defaults--no-defaults除了登录文件,不从任何选项文件读取默认选项。Do not read default options from any option file other than the login file.
命令行格式Command-Line Format --no-login-paths不要从登录路径文件中读取登录路径。Do not read login paths from the login path file.
命令行格式Command-Line Format --passphrase=phrase类型Type 字符串String 默认值Default Value [none][none]指定 CA 密钥密码短语。Specify a CA key pass phrase.
命令行格式Command-Line Format --node-id=#类型Type 整数Integer 默认值Default Value 0最小值Minimum Value 0最大值Maximum Value 255为具有指定节点 ID 的节点创建或签署密钥。Create or sign a key for the node having the specified node ID.
命令行格式Command-Line Format --node-type=set类型Type 设置Set 默认值Default Value mgmd,db,api为集合
(mgmd,db,api)中指定的类型创建或签署密钥。Create or sign keys for the specified type or types from the set(mgmd,db,api).命令行格式Command-Line Format --pending将密钥和证书保存为待定状态,而不是激活状态。Save keys and certificates as pending, rather than active.
命令行格式Command-Line Format --print-defaults打印程序参数列表,然后退出。Print the program argument list, then exit.
命令行格式Command-Line Format --promote将待处理的文件提升为活动状态,然后退出。Promote pending files to active, then exit.
命令行格式Command-Line Format --remote-CA-host=hostname类型Type 字符串String 默认值Default Value [none][none]指定远程 CA 主机的地址或主机名。Specify the address or hostname of a remote CA host.
命令行格式Command-Line Format --remote-exec-path类型Type 路径名Path name 默认值Default Value [none][none]提供在使用
--remote-CA-host指定的远程 CA 主机上的可执行文件的完整路径。Provide the full path to an executable on the remote CA host specified with--remote-CA-host.命令行格式Command-Line Format --remote-openssl在使用
--remote-CA-host指定的远程 CA 主机上使用 OpenSSL 对密钥进行签名。Use OpenSSL for signing of keys on the remote CA host specified with--remote-CA-host.命令行格式Command-Line Format --replace-by=#类型Type 整数Integer 默认值Default Value -10最小值Minimum Value -128最大值Maximum Value 127建议一个周期性检查的证书更换日期,以 CA 到期日后的天数表示。使用负数表示在到期日前的天数。Suggest a certificate replacement date for periodic checks, as a number of days after the CA expiration date. Use a negative number to indicate days before expiration.
命令行格式Command-Line Format --rotate-CA用较新的 CA 替换旧的 CA。新 CA 可以使用 OpenSSL 创建,或者您可以允许 ndb_sign_keys 创建新 CA,在这种情况下,新 CA 会通过中间 CA 证书创建,并由旧 CA 签名。Replace an older CA with a newer one. The new CA can be created using OpenSSL, or you can allow ndb_sign_keys to create the new one, in which case the new CA is created with an intermediate CA certificate, signed by the old CA.
命令行格式Command-Line Format --schedule=list类型Type 字符串String 默认值Default Value 120,10,130,10,150,0为证书分配到期日的计划。该计划定义为由六个整数组成的逗号分隔列表,格式如下所示:Assign a schedule of expiration dates to certificates. The schedule is defined as a comma-delimited list of six integers, in the format shown here:
api_valid,api_extra,dn_valid,dn_extra,mgm_valid,mgm_extra
这些值定义如下:These values are defined as follows:
api_valid:客户端证书的固定有效天数。api_valid: A fixed number of days of validity for client certificates.api_extra:客户端证书的额外天数。api_extra: A number of extra days for client certificates.dn_valid:数据节点证书的固定有效天数的客户端证书。dn_valid: A fixed number of days of validity for client certificates for data node certificates.dn_extra:数据节点证书的额外天数。dn_extra: A number of extra days for data node certificates.mgm_valid:管理服务器证书的固定有效天数。mgm_valid: A fixed number of days of validity for management server certificates.mgm_extra:管理服务器证书的额外天数。mgm_extra: A number of extra days for management server certificates.
换句话说,对于每种节点类型(API 节点、数据节点、管理节点),证书的有效期为一个固定的整天数,加上一个不超过额外天数的随机时间。默认计划如下:In other words, for each node type (API node, data node, management node), certificates are created with a lifetime equal to a whole fixed number of days, plus some random amount of time less than or equal to the number of extra days. The default schedule is shown here:
--schedule=120,10,130,10,150,0
Following the default schedule, client certificates begin expiring on the 120th day, and expire at random intervals over the next 10 days; data node certificates expire at random times between the 130th and 140th days; and management node certificates expire on the 150th day (with no random interval following).
命令行格式Command-Line Format --sign禁用者Disabled by skip-sign创建已签名的证书;默认启用。使用
--skip-sign来创建证书签名请求。Create signed certificates; enabled by default. Use--skip-signto create certificate signing requests instead.命令行格式Command-Line Format --skip-sign创建证书签名请求,而不是已签名的证书。Create certificate signing requests instead of signed certificates.
命令行格式Command-Line Format --stdio从
stdin读取证书签名请求,并将 X.509 写入stdout。Read certificate signing requests fromstdin, and write X.509 tostdout.命令行格式Command-Line Format --to-dir=dirname类型Type 目录名称Directory name 默认值Default Value [none][none]指定已创建文件的输出目录。对于私钥文件,可以使用
--keys-to-dir覆盖此设置。Specify the output directory for created files. For private key files, this can be overriden using--keys-to-dir.命令行格式Command-Line Format --usage打印帮助文本,然后退出(
--help的别名)。Print help text, then exit (alias for--help).命令行格式Command-Line Format --version打印版本信息,然后退出。Print version information, then exit.