简体   繁体   English

Azure 密钥保管库:合并证书

[英]Azure key vault: Merge certificate

I'm trying to understand the merge API of Azure Key vault.我试图了解 Azure Key Vault 的合并 API。 What is the use case of it?它的用例是什么? https://docs.microsoft.com/en-us/rest/api/keyvault/mergecertificate/mergecertificate https://docs.microsoft.com/en-us/rest/api/keyvault/mergecertificate/mergecertificate

The doc says医生说

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

One use case I understand here is to create CSR in key vault, get it signed by your CA and then merge it to the CSR in key vault to complete the certificate creation.我在这里了解的一个用例是在密钥库中创建 CSR,由您的 CA 对其进行签名,然后将其合并到密钥库中的 CSR 以完成证书创建。

But what do we mean by merging a certificate chain?但是合并证书链是什么意思? Does it mean the certificate chain that was used to sign the CSR?这是否意味着用于签署 CSR 的证书链?

Yes, merging the chain means that the whole chain, which starts with the certificate that is generated for CSR.是的,合并链意味着整个链,从为 CSR 生成的证书开始。

So, to have a local test using OpenSSL 1.1.1因此,使用 OpenSSL 1.1.1 进行本地测试

  1. Generate CA生成 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. Generate Intermediate CA生成中间 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. Generate request using Azure KeyVault and download CSR to test.csr file.使用 Azure KeyVault 生成请求并将 CSR 下载到 test.csr 文件。 Assuming using keyvault test-kv and certificate with name test .假设使用 keyvault test-kv和名称为test的证书。

  2. Sign the request using intermediate CA使用中间 CA 签署请求

openssl x509 -CA inter.crt -CAkey inter.key -days 365 -req -in test.csr -set_serial 03 -out test.crt
  1. Bundle certificate together with intermediate and CA to PEM format (just concatenate those text files in proper order)将证书与中间证书和 CA 捆绑到 PEM 格式(只需按正确顺序连接这些文本文件)
cat test.crt inter.crt ca.crt > test-chain.pem
  1. Merge the certificate chain in Azure KeyVault合并 Azure KeyVault 中的证书链
az keyvault certificate  pending merge --vault-name test-kv --name test --file test-chain.pem

Additional note about formats:关于格式的附加说明:
The certificate content type can be set to either PKCS12 or PEM upon creation in Azure KeyVault.在 Azure KeyVault 中创建证书内容类型时,可以将其设置为 PKCS12 或 PEM。 As result merged certificate is exported/downloaded结果合并证书被导出/下载

  • using PFX format for certificate created with PKCS12 content type对使用 PKCS12 内容类型创建的证书使用 PFX 格式
  • using PEM format for certificate created with PEM content type对使用 PEM 内容类型创建的证书使用 PEM 格式

The format of the chain bundle for merging, however, does not depend on that content type.但是,用于合并的链束的格式不依赖于该内容类型。 It only depends on the method that is used to perform the merge:它仅取决于用于执行合并的方法:

The following command can be used to create a P7B file containing the chain:以下命令可用于创建包含链的 P7B 文件:

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

When certificate that was merged together with the chain is downloaded in PEM, it contains the whole chain already.当与链合并在一起的证书在 PEM 中下载时,它已经包含整个链。 When certificate is downloaded in PFX, to extract individual certificates the following command can be used to convert to PEM, containing only certificates (omitting the private key):在 PFX 中下载证书时,要提取单个证书,可以使用以下命令转换为 PEM,仅包含证书(省略私钥):

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

Then chain.pem can be opened with text editor and individual certificates can be extracted to separate crt files然后可以使用文本编辑器打开chain.pem,并且可以将单个证书提取到单独的crt文件中

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 从 azure 密钥库证书中分离私钥和证书 - Separating private key and certificate from azure key vault certificate 如何从 Azure 密钥库中的证书获取私钥? - How to Get Private Key from Certificate in an Azure Key Vault? Azure 密钥保管库在 Python 中创建 - Azure key vault create in Python 无法使用 python 从 Azure Key Vault 获取机密/证书 | “KeyVaultManagementClient”对象没有“get_secret”属性 - unable to get the secret / certificate from Azure Key Vault using python | 'KeyVaultManagementClient' object has no attribute 'get_secret' 使用 Python 从 Azure Key Vault 解码 JsonWebKey - Decoding JsonWebKey from Azure Key Vault with Python 使用 DefaultAzureCredential 在本地对 Azure Key Vault 进行身份验证 - Authenticating to Azure Key Vault locally using DefaultAzureCredential Python Azure Function - 使用密钥库的 MSI 身份验证 - Python Azure Function - MSI Authentication with Key Vault 使用 az cli 解密 Azure Key Vault 密码 - Azure Key Vault password decryption with az cli Azure Key Vault 是否支持客户端证书? - Does Azure Key Vault support Client Certificates? 无法使用 python 访问 azure key vault secret - Cannot access azure key vault secret with python
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM