【问题标题】:Azure key vault: Merge certificateAzure 密钥保管库:合并证书
【发布时间】:2020-10-19 17:41:20
【问题描述】:

我正在尝试了解 Azure Key Vault 的合并 API。它的用例是什么? https://docs.microsoft.com/en-us/rest/api/keyvault/mergecertificate/mergecertificate

医生说

The MergeCertificate operation performs the merging of a certificate or certificate chain with a key pair currently available in the service. 

我在这里了解的一个用例是在密钥保管库中创建 CSR,由您的 CA 对其进行签名,然后将其合并到密钥保管库中的 CSR 以完成证书创建。

但是合并证书链是什么意思?是指用于签署 CSR 的证书链吗?

【问题讨论】:

  • 这有什么更新吗?

标签: python azure azure-keyvault


【解决方案1】:

是的,合并链意味着整个链,从为 CSR 生成的证书开始。

因此,使用 OpenSSL 1.1.1 进行本地测试

  1. 生成 CA
openssl req -new -newkey rsa:2048 -nodes -out ca.csr -keyout ca.key -extensions v3_ca
openssl x509 -signkey ca.key -days 365 -req -in ca.csr -set_serial 01 -out ca.crt
  1. 生成中间 CA
openssl req -new -newkey rsa:2048 -nodes -out inter.csr -keyout inter.key -addext basicConstraints=CA:TRUE
openssl x509 -CA ca.crt -CAkey ca.key -days 365 -req -in inter.csr -set_serial 02 -out inter.crt
  1. 使用 Azure KeyVault 生成请求并将 CSR 下载到 test.csr 文件。假设使用 keyvault test-kv 和名称为 test 的证书。

  2. 使用中间 CA 签署请求

openssl x509 -CA inter.crt -CAkey inter.key -days 365 -req -in test.csr -set_serial 03 -out test.crt
  1. 将证书与中间证书和 CA 捆绑到 PEM 格式(只需按正确顺序连接这些文本文件)
cat test.crt inter.crt ca.crt > test-chain.pem
  1. 在 Azure KeyVault 中合并证书链
az keyvault certificate  pending merge --vault-name test-kv --name test --file test-chain.pem

关于格式的附加说明:
在 Azure KeyVault 中创建证书内容类型时,可以将其设置为 PKCS12 或 PEM。结果合并的证书被导出/下载

  • 对使用 PKCS12 内容类型创建的证书使用 PFX 格式
  • 对使用 PEM 内容类型创建的证书使用 PEM 格式

但是,用于合并的链束的格式不依赖于该内容类型。它仅取决于用于执行合并的方法:

以下命令可用于创建包含链的 P7B 文件:

openssl crl2pkcs7 -nocrl -certfile test.crt -out test.p7b -certfile inter.crt -certfile ca.crt

当与链合并在一起的证书在 PEM 中下载时,它已经包含整个链。 在 PFX 中下载证书时,要提取单个证书,可以使用以下命令转换为 PEM,仅包含证书(省略私钥):

openssl pkcs12 -in downloaded-cert.pfx -nokeys -nodes -out chain.pem

然后可以使用文本编辑器打开chain.pem,并可以将单个证书提取到单独的crt文件中

【讨论】:

    猜你喜欢
    • 2022-01-18
    • 2020-04-04
    • 2017-01-05
    • 1970-01-01
    • 1970-01-01
    • 2016-10-13
    • 1970-01-01
    • 2020-06-28
    • 1970-01-01
    相关资源
    最近更新 更多