Neb*_*tic 2 ssl cname certificate a-records freeipa
不久前我想知道如何为 cname 创建 ssl 证书。这是因为我们总是为虚拟机使用通用 a 记录。用户应通过 SSL 通过其服务名称来访问在这些虚拟机上运行的服务。我们使用 FreeIPA 作为我们的证书颁发机构。
有时你寻找一个答案很长时间,并在多个网站上找到答案,但这些答案都不是很清楚。我将通过一个示例来解释我的答案,以展示使用cname 和不使用cname 向 FreeIPA 请求证书的差异。
我们创建一个假想的虚拟机,其 a 记录为 abc955-xy.example.com。在这台机器上我们将运行 postgres。因此,为了方便起见,cname 将为 postgresql.example.com。首先,我们为 abc955-xy.example.com 创建一个证书,该证书仅对 fqdn 有效。其次,我们为 cname 创建一个证书,该证书对于 FQDN 也有效。
没有 cname 的证书
# Generate a private key
openssl genrsa -out abc955-xy.example.com.key 4096
# Add the host to FreeIPA
ipa host-add abc955-xy.example.com --force
# Create a host principal for the service HTTP
ipa service-add HTTP/abc955-xy.example.com
# Add the host principal to the host
ipa service-add-host HTTP/abc955-xy.example.com --host abc955-xy.example.com
# Request a certificate for the host, using the principal and private key
ipa-getcert request -r -f abc955-xy.example.com.crt -k abc955-xy.example.com.key \
-K HTTP/abc955-xy.example.com -D abc955-xy.example.com
Run Code Online (Sandbox Code Playgroud)
包含 cname 的证书
# Generate a private key
openssl genrsa -out postgresql.example.com.key 4096
# Add the host to FreeIPA, using the cname
ipa host-add postgresql.example.com --force
# Create a host principal for the service HTTP
ipa service-add HTTP/abc955-xy.example.com
# Create a principal for the service HTTP with the cname
ipa service-add HTTP/postgresql.example.com --force
# Add the cname principal to the host
ipa service-add-host HTTP/postgresql.example.com --host abc955-xy.example.com
# Request a certificate for the host, using the principal and private key and cname
ipa-getcert request -r -f postgresql.example.com.crt -k postgresql.example.com.key\
-K HTTP/postgresql.example.com -D postgresql.example.com -D abc955-xy.example.com
Run Code Online (Sandbox Code Playgroud)
除了一些命名差异之外,两个选项之间的主要区别在于,您将带有 cname 的 HTTP 主体添加到主机,而不是带有 fqdn 的 HTTP 主体。
注意:由于 Chrome 和 Chromium 等浏览器自版本 65 起仅接受具有使用者备用名称 (SAN) 的证书,因此您还需要向没有 cname 的证书添加使用者备用名称。这就是 ipa-getcert 请求中选项 -D 的来源。对于没有 cname 的证书,您必须提供 FQDN。
| 归档时间: |
|
| 查看次数: |
2079 次 |
| 最近记录: |