本节将帮助用户使用 EST 协议配置 OpenXPKI CA 3.x.x 版本。
注意:
使用 PuTTY 或其他客户端来连接机器。
从客户端,运行
命令以转到 root 用户。输入 root 用户密码。
在 nano /etc/apt/sources.list 中,更改用于安装更新的来源。
更新该文件。例如:
# # deb cdrom:[Debian GNU/Linux testing _Buster_ - Official Snapshot amd64 DVD Binary-1 20190527-04:04]/ buster contrib main # deb cdrom:[Debian GNU/Linux testing _Buster_ - Official Snapshot amd64 DVD Binary-1 20190527-04:04]/ buster contrib main deb http://security.debian.org/debian-security buster/updates main contrib deb-src http://security.debian.org/debian-security buster/updates main contrib # buster-updates, previously known as 'volatile' # A network mirror was not selected during install.The following entries # are provided as examples, but you should amend them as appropriate # for your mirror of choice.# deb http://ftp.debian.org/debian/ buster-updates main deb-src http://ftp.debian.org/debian/ buster-updates main deb http://ftp.us.debian.org/debian/ buster main
保存该文件。
运行以下命令:
更新服务器中的 CA 证书列表,使用
命令。安装 en_US.utf8 locale ,使用
命令。选择 en_US.UTF-8 UTF-8 locale,然后将其设为系统的默认 locale。
检查您使用
生成的 locale。C C.UTF-8 en_IN en_IN.utf8 en_US.utf8 POSIX
复制 OpenXPKI 软件包的指纹,使用
命令。在此例中,复制 /home 中的键。键入
作为值。运行以下命令:
使用
命令添加软件包。使用
和 命令将存储库添加到来源列表 (buster) 中。使用
命令安装 MySQL 和 Perl MySQL 绑定。使用
命令安装 apache2.2-common。在 nano /etc/apt/sources.list 中,安装 fastcgi 模块来加速用户界面。
在该文件中添加
行,然后保存该文件。运行以下命令:
使用
命令启用 fastcgi 模块。使用
命令安装 OpenXPKI 核心软件包。重新启动 Apache 服务器,使用
命令。使用
命令检查是否安装成功。创建空数据库,然后使用
命令分配数据库用户。注意:
CREATE DATABASE openxpki CHARSET utf8; CREATE USER 'openxpki'@'localhost' IDENTIFIED BY 'openxpki'; GRANT ALL ON openxpki.* TO 'openxpki'@'localhost'; flush privileges;
如果 MySQL 服务没有运行,则运行
来启动该服务。键入
以退出 MySQL。将所使用的凭证存储在 /etc/openxpki/config.d/system/database.yaml 中。
main: debug: 0 type: MariaDB name: openxpki host: localhost port: 3306 user: openxpki passwd: openxpki
保存该文件。
对于空数据库模式,请从提供的模式文件中运行
。键入数据库的密码。
使用
命令运行该脚本。使用
命令确认设置。=== functional token === scep (scep): Alias : scep-1 Identifier: YsBNZ7JYTbx89F_-Z4jn_RPFFWo NotBefore : 2015-01-30 20:44:40 NotAfter : 2016-01-30 20:44:40 vault (datasafe): Alias : vault-1 Identifier: lZILS1l6Km5aIGS6pA7P7azAJic NotBefore : 2015-01-30 20:44:40 NotAfter : 2016-01-30 20:44:40 ca-signer (certsign): Alias : ca-signer-1 Identifier: Sw_IY7AdoGUp28F_cFEdhbtI9pE NotBefore : 2015-01-30 20:44:40 NotAfter : 2018-01-29 20:44:40 === root ca === current root ca: Alias : root-1 Identifier: fVrqJAlpotPaisOAsnxa9cglXCc NotBefore : 2015-01-30 20:44:39 NotAfter : 2020-01-30 20:44:39 upcoming root ca: not set
使用
命令检查是否安装成功。Starting OpenXPKI... OpenXPKI Server is running and accepting requests. DONE.
执行以下操作以访问 OpenXPKI 服务器:
从 Web 浏览器,键入
。在
文件中添加用户名及其对应的密码。要添加用户名和密码,请执行以下操作:查看 /home/pkiadm ,然后查看 nano userdb.yaml 。
粘贴以下内容:
estRA: digest:"{ssha256}somePassword” role: RA Operator
输入用户名和密码。
创建一个证书请求,然后进行测试。
要手动配置 OpenXPKI CA,请创建以下内容:
根 CA 证书。如需更多信息,请参阅 创建根 CA 证书 。
CA 签名者证书(由根 CA 签名的证书)。如需更多信息,请参阅 创建签名者证书 。
保管库证书(自签名证书)。如需更多信息,请参阅 创建保管库证书 。
Web 证书(通过签名者证书签名的证书)。如需更多信息,请参阅 设置 Web 服务器 。
注意:
对于 3.10 或更高版本,您可以使用“openxpkiadm alias”命令直接管理密钥:
运行 mkdir -p /etc/openxpki/local/keys 命令创建目录。该目录的默认位置为 /etc/openxpki/local/keys 。
运行 openxpkictl start 命令启动服务器。
在此例中,我们使用 /etc/certs/openxpki_democa/ 目录来生成证书。但您可以使用任何目录。
OpenSSL 配置文件包含用于生成和签署证书请求的 X.509 扩展。
运行以下命令:
# x509_extensions = v3_ca_extensions # x509_extensions = v3_issuing_extensions # x509_extensions = v3_datavault_extensions # x509_extensions = v3_scep_extensions # x509_extensions = v3_web_extensions # x509_extensions = v3_ca_reqexts # not for root self-signed, only for issuing ## x509_extensions = v3_datavault_reqexts # not required self-signed # x509_extensions = v3_scep_reqexts # x509_extensions = v3_web_reqexts [ req ] default_bits = 4096 distinguished_name = req_distinguished_name [ req_distinguished_name ] domainComponent = Domain Component commonName = Common Name [ v3_ca_reqexts ] subjectKeyIdentifier = hash keyUsage = digitalSignature, keyCertSign, cRLSign [ v3_datavault_reqexts ] subjectKeyIdentifier = hash keyUsage = keyEncipherment extendedKeyUsage = emailProtection [ v3_scep_reqexts ] subjectKeyIdentifier = hash [ v3_web_reqexts ] subjectKeyIdentifier = hash keyUsage = critical, digitalSignature, keyEncipherment extendedKeyUsage = serverAuth, clientAuth [ v3_ca_extensions ] subjectKeyIdentifier = hash keyUsage = digitalSignature, keyCertSign, cRLSign basicConstraints = critical,CA:TRUE authorityKeyIdentifier = keyid:always,issuer [ v3_issuing_extensions ] subjectKeyIdentifier = hash keyUsage = digitalSignature, keyCertSign, cRLSign basicConstraints = critical,CA:TRUE authorityKeyIdentifier = keyid:always,issuer:always crlDistributionPoints = URI:https://FQDN of your system/openxpki/CertEnroll/MYOPENXPKI.crl authorityInfoAccess = caIssuers;URI:https://FQDN of your system/download/MYOPENXPKI.crt [ v3_datavault_extensions ] subjectKeyIdentifier = hash keyUsage = keyEncipherment extendedKeyUsage = emailProtection basicConstraints = CA:FALSE authorityKeyIdentifier = keyid:always,issuer [ v3_scep_extensions ] subjectKeyIdentifier = hash basicConstraints = CA:FALSE authorityKeyIdentifier = keyid,issuer [ v3_web_extensions ] subjectKeyIdentifier = hash keyUsage = critical, digitalSignature, keyEncipherment extendedKeyUsage = serverAuth, clientAuth basicConstraints = critical,CA:FALSE subjectAltName = DNS:FQDN of est server crlDistributionPoints = URI:https://FQDN of your system/openxpki/CertEnroll/MYOPENXPKI_ISSUINGCA.cr authorityInfoAccess = caIssuers;URI:https://FQDN of your system/download/MYOPENXPKI_ISSUINGCA.crt
将 IP 地址和 CA 证书名称替换为您的设置信息。
保存该文件。
您可以创建自签名的根 CA 证书,也可以生成证书请求并让根 CA 对其进行签名。
运行以下命令:
使用
命令将请求中的主题替换为您的 CA 信息。使用
命令获取由根 CA 签名的证书。请转到用于保存 ca-root-1.crt 的 /etc/certs/openxpki_democa/ 。
运行以下命令:
注意:
运行以下命令:
使用
命令将请求中的主题更改为您的 CA 信息。运行以下命令:
运行以下命令:
使用 apache2 restart 命令重新启动 Apache 服务。
运行以下命令来检查是否成功导入文件:
=== functional token === ca-signer (certsign): Alias : ca-signer-2 Identifier: XjC6MPbsnyfLZkI9Poi9vm4Z5rk NotBefore : 2022-04-06 10:03:01 NotAfter : 2032-04-03 10:03:01 vault (datasafe): Alias : vault-2 Identifier: G8ekluAsskGVC0N-jZhB2n9kvdM NotBefore : 2022-04-06 09:53:57 NotAfter : 2025-04-10 09:53:57 scep (scep): not set ratoken (cmcra): not set === root ca === current root ca: Alias : root-2 Identifier: prTHU5vCfcJuCnQWyb5wUknvXQM NotBefore : 2022-04-06 09:40:27 NotAfter : 2032-01-04 09:40:27
更改
文件中的值。取消注释
下的“cache: daemon”:secret: default: label: Global Secret group export: 0 method: literal value: root cache: daemon
运行
命令。Starting OpenXPKI...OpenXPKI Server is running and accepting requests.DONE.
访问 OpenXPKI 服务器:
从 Web 浏览器,键入
。在
文件中添加用户名及其对应的密码:查看 /home/pkiadm ,然后查看 nano userdb.yaml 。
粘贴以下内容:
estRA: digest:"{ssha256}somePassword” role: RA Operator
要生成密码,请键入
。此时会出现一条显示密码和 ssha256 加密密码的消息。复制密码,然后将其粘贴到任何用户的摘要中。
键入您的用户名和密码。
创建一个证书请求,然后进行测试。
使用
命令停止 OpenXPKI 服务。在 nano /etc/openxpki/config.d/realm/democa/publishing.yaml 中,将
部分更新为以下内容:class: Connector::Builtin::File::Path LOCATION: /var/www/openxpki/CertEnroll/ file: "[% ARGS.0 %].crl" content: "[% pem %]"
在 nano /etc/openxpki/config.d/realm/democa/profile/default.yaml 中,更新以下内容:
部分
critical: 0 uri: - https://FQDN of the est/openxkpi/CenrtEnroll/[% ISSUER.CN.0 %].crl - ldap://localhost/[% ISSUER.DN %]
部分
critical: 0 ca_issuers: http://FQDN of the est/download/MYOPENXPKI.crt ocsp: http://ocsp.openxpki.org/
根据您的 CA 服务器更改 IP 地址和 CA 证书名称。
在 nano /etc/openxpki/config.d/realm/democa/crl/default.yaml 中,执行以下操作:
如有必要,请更新
和 。将
添加到以下部分:extensions: authority_info_access: critical: 0 # ca_issuers and ocsp can be scalar or list ca_issuers: https://FQDN of the est/download/MYOPENXPKI.crt #ocsp: http://ocsp.openxpki.org/
根据您的 CA 服务器更改 IP 地址和 CA 证书名称。
使用
命令启动 OpenXPKI 服务。在创建 CRL 之后,您必须发布它们以供所有人访问。
使用
命令停止 Apache 服务。为 /var/www/openxpki/ 目录中的 CRL 创建 CertEnroll 目录。
将 openxpki 设置为该目录的所有者,然后配置相应的权限以允许 Apache 读取和执行内容并允许其他服务只读取内容。
chown openxpki /var/www/openxpki/CertEnroll
chmod 755 /var/www/openxpki/CertEnroll
使用
命令在 Apache alias.conf 文件中添加一个引用。在
部分后面,添加以下内容:Alias /CertEnroll/ "/var/www/openxpki/CertEnroll/" <Directory "/var/www/openxpki/CertEnroll"> Options FollowSymlinks AllowOverride None Require all granted </Directory>
使用 nano /etc/apache2/apache2.conf 命令在 apache2.conf 文件中添加一个引用。
在
部分中添加以下内容:<Directory /var/www/openxpki/CertEnroll> Options FollowSymlinks AllowOverride None Allow from all </Directory>
使用
命令启动 Apache 服务。使用
命令停止 OpenXPKI 服务。在 /etc/openxpki/config.d/realm/democa/est/default.yaml 中,更新
部分:eligible: initial: value@: connector:scep.generic.connector.initial args: '[% context.cert_subject_parts.CN.0 %]' expect: - Build - New
eligible: initial: value: 1 # value@: connector:scep.generic.connector.initial # args: '[% context.cert_subject_parts.CN.0 %]' # expect: # - Build # - New
注意:
保存该文件。
使用
命令启动 OpenXPKI 服务。在 OpenXPKI 中,您可以在同一系统中配置多个 PKI 结构。以下主题说明如何为名为 democa-two 的 MVE 创建另一个领域。
为 /etc/openxpki/config.d/realm 中的第二个领域创建名为 democa2 的目录。
将 /etc/openxpki/config.d/realm/ca-one 示例目录树复制到 realm 目录内的新目录 ( cp -r /etc/openxpki/config.d/realm.tpl/*/etc/openxpki/config.d/realm/democa2 ) 中。
在 /etc/openxpki/config.d/system/realms.yaml 中,更新以下部分:
# This is the list of realms in this PKI # You only need to enable the realms which are visible on the server democa: label: Verbose name of this realm baseurl: https://pki.example.com/openxpki/ #democa2: # label: Verbose name of this realm # baseurl: https://pki.acme.org/openxpki/
# This is the list of realms in this PKI # You only need to enable the realms which are visible on the server democa: label: Example.org Demo CA baseurl: https://pki.example.com/openxpki/ democa2: label: Example.org Demo CA2 baseurl: https://pki.example.com/openxpki/
保存该文件。
您可以使用由 URI 的权限部分和可选标签(例如,www.example.com:80 和 arbitraryLabel1)组成的元组来配置 EST 端点。在以下说明中,我们使用以下两个 PKI 领域:
和 。将默认配置文件复制到 cp /etc/openxpki/est/default.conf /etc/openxpki/est/democa.conf 中。
在 nano /etc/openxpki/est/democa.conf 中,将领域值更改为
。在 cp /etc/openxpki/est/default.conf /etc/openxpki/est/democa2.conf 中创建另一个配置文件。
在 nano /etc/openxpki/est/democa2.conf 中,将领域值更改为
。将 default.yaml 文件复制到以下位置:
cp /etc/openxpki/config.d/realm/democa/est/default.yaml
/etc/openxpki/config.d/realm/democa/est/democa.yaml
将 default.yaml 文件复制到以下位置:
cp /etc/openxpki/config.d/realm/democa2/est/default.yaml
/etc/openxpki/config.d/realm/democa2/est/democa2.yaml
使用
命令重新启动 OpenXPKI 服务。选择以下 URL 以通过 Web 浏览器打开与领域对应的 EST 服务器:
- http://ipaddress/est/democa
- http://ipaddress/est/democa2
如果您想区分不同 PKI 领域的登录凭证和默认证书模板,则可能需要高级配置。
以下说明介绍了如何在第二个领域中生成签名者证书。您可以使用与第一个领域中相同的根证书和保管库证书。
在 nano /etc/certs/openxpki_democa2/openssl.conf 中创建一个 OpenSSL 配置文件。
转到第一个领域的保管库证书目录,然后从第一个领域中导入证书。
运行以下代码:
运行以下命令:
键入您的密码。
创建签名者证书。如需更多信息,请参阅 创建签名者证书 。
使用 openxpkiadm alias --realm democa2 命令检查是否导入成功。
为第二个领域生成 CRL。如需更多信息,请参阅 生成 CRL 信息 。
发布此领域的 CRL。如需更多信息,请参阅 发布 CRL 信息 。
使用 openxpkictl restart 命令重新启动 OpenXPKI 服务。
Stopping OpenXPKI Stopping gracefully, 3 (sub)processes remaining... DONE.Starting OpenXPKI...OpenXPKI Server is running and accepting requests.DONE.
默认情况下,在 OpenXPKI 中一次只能激活一个具有相同主题名称的证书。但是,当强制执行多个命名证书时,必须同时存在具有相同主题名称的多个活动证书。
在 /etc/openxpki/config.d/realm/REALM NAME/est/< REALM NAME >.yaml 的
部分中,将 的值从 更改为 。注意:
使用
命令重新启动 OpenXPKI 服务。默认情况下,Apache 在端口号 443 上侦听 https。为 OpenXPKI CA 设置默认端口号以避免发生冲突。
在 /etc/apache2/ports.conf 中,将 443 端口修改为任何其他端口。例如:
Listen 80 <IfModule ssl_module> Listen 443 </IfModule> <IfModule mod_gnutls.c> Listen 443 </IfModule>
Listen 80 <IfModule ssl_module> Listen 9443 </IfModule> <IfModule mod_gnutls.c> Listen 9443 </IfModule>
在 /etc/apache2/sites-available/openxpki.conf 中,添加或修改
部分以映射新端口。例如, 更改为 。在 /etc/apache2/sites-available/default-ssl.conf 中,添加或修改
部分以映射新端口。例如,将 更改为 。使用
命令重新启动 Apache 服务器。在 tinddopenxpkiweb01.dhcp.dev.lexmark.com:9443 (RSA): 中,输入 SSL/TLS 密钥的密码。
要检查状态,请运行
。OpenXPKI SCEP URL 现在为 https://ipaddress ,而 Web URL 为 FQDN:9443/openxpki 。运行以下命令:
创建一个有权访问服务器的用户帐户。输入以下详细信息:
htpasswd -c /etc/apache2/.htpasswd <username> New password: Re-type new password: Adding password for user <username>
转到以下目录:
。在 nano openxpki.conf 中,将以下行添加到
中:#HTTPS BASIC AUTH FOR LABELS Location /.well-known/est/*/simpleenroll AuthType Basic AuthName "estrealm" AuthUserFile /etc/apache2/.htpasswd require valid-user </Location> #HTTPS BASIC AUTH FOR NO LABEL <Location /.well-known/est/simpleenroll> AuthType Basic AuthName "estrealm" AuthUserFile /etc/apache2/.htpasswd require valid-user </Location>
将
添加到同一虚拟主机块中的 SSLEngine 之前。ServerAlias * DocumentRoot /var/www/ ErrorDocument 401 %{unescape:%00} SSLEngine On
使用 service apache2 restart 命令重新启动 apache2 服务。
转到以下目录:
。对于 nano openxpki.conf 中的必需主机,添加 SSLVerifyClient require 。
例如,如果您使用端口 443,请将 VirtualHost 部分修改为:
<VirtualHost *:443> SSLVerifyClient require </VirtualHost>
移除 SSLVerifyClient optional_no_ca 命令。
保存该文件,然后键入
以退出 MySQL。转到以下目录:
。打开 default.yaml 和 democa.yaml 。
运行以下命令:
在 authorized_signer 部分中,添加以下内容:
authorized_signer: rule2: subject: CN=,.
例如,如果您的客户端证书主题名称为 test123 ,请将以下内容添加到
部分中:authorized_signer: rule1: # Full DN subject: CN=.+:pkiclient,. rule2: subject: CN=test123,.*
保存该文件,然后键入
以退出 MySQL。使用
命令重新启动 OpenXPKI 服务。使用
命令重新启动 Apache 服务。启用 CRL 信息时可能会出现 SAN 不匹配错误。此错误表明 IP 或主机名与 Web 证书中的 SAN 值不匹配。为避免出现此错误,请在 CRL 路径中使用 FQDN,而不是使用 IP。您还可以在 SAN 字段中配置 Web 证书并使用系统的 FQDN。
如果系统状态页面显示您的 ca-signer-1 和 vault-1 令牌处于脱机状态,请执行以下操作:
在 /etc/openxpki/config.d/realm/realm name/crypto.yaml 中,更改对应的密钥值。
重新启动 OpenXPKI 服务。