使用密钥保管库生成客户端证书



对于我们的点到站点VPN,我们希望创建一个根证书。 因此,我们可以为所有需要登录我们的VPN的合作伙伴创建任意数量的客户端证书。(Azure 虚拟网络(

手动执行此操作非常完美。我们生成一个充当根 CA 的证书(自签名(。我们能够像这样在powershell中做到这一点:

$cert = New-SelfSignedCertificate -Type Custom -KeySpec Signature -Subject "CN=Kratos Point To Site VPN Root Certificate Win10" -KeyExportPolicy Exportable -HashAlgorithm sha256 -KeyLength 2048 -CertStoreLocation "Cert:CurrentUserMy" -KeyUsageProperty Sign -KeyUsage CertSign
$clientCert = New-SelfSignedCertificate -Type Custom -KeySpec Signature -Subject "CN=Digicreate Point To Site VPN Client Certificate Win10" -KeyExportPolicy Exportable -HashAlgorithm sha256 -KeyLength 2048 -CertStoreLocation "Cert:CurrentUserMy" -Signer $cert -TextExtension @("2.5.29.37={text}1.3.6.1.5.5.7.3.2")

但是,我们更喜欢使用密钥保管库进行证书管理。想法是使用以下命令直接在密钥保管库中创建证书: 添加 AzureKeyVaultCertificate (私钥不可导出(

创建根证书非常有效。但我无法找到如何使用密钥保管库中的"签名"操作对新证书进行签名。

你有关于如何做到这一点的样本吗?

请参阅 https://blogs.technet.microsoft.com/kv/2016/09/26/get-started-with-azure-key-vault-certificates/中的"手动创建证书并由 CA 签名"部分

但我想基于此根创建客户端证书 具有 Azure 密钥保管库 cmdlet 的证书。这可能吗?

您的意思是您要下载证书吗? 如果是,我们可以使用此脚本下载它:

将私有证书下载到您的 D:\cert:

$kvSecret = Get-AzureKeyVaultSecret -VaultName 'jasontest2' -Name 'TestCert01'
$kvSecretBytes = [System.Convert]::FromBase64String($kvSecret.SecretValueText)
$certCollection = New-Object System.Security.Cryptography.X509Certificates.X509Certificate2Collection
$certCollection.Import($kvSecretBytes,$null,[System.Security.Cryptography.X509Certificates.X509KeyStorageFlags]::Exportable)
$protectedCertificateBytes = $certCollection.Export([System.Security.Cryptography.X509Certificates.X509ContentType]::Pkcs12, 'test')
$pfxPath = 'D:certtest.pfx'
[System.IO.File]::WriteAllBytes($pfxPath, $protectedCertificateBytes)

将公共证书下载到 D:\cert:

$cert = Get-AzureKeyVaultCertificate -VaultName 'jasontest2' -Name 'TestCert01'
$filePath ='D:certTestCertificate.cer'
$certBytes = $cert.Certificate.Export([System.Security.Cryptography.X509Certificates.X509ContentType]::Cert)
[System.IO.File]::WriteAllBytes($filePath, $certBytes)

更新:

$certificateOperation.CertificateSigningRequest 是证书的 base4 编码证书签名请求。

Import-AzureKeyVaultCertificate -VaultName $vaultName -Name $certificateName -FilePath C:testOutputCertificateFile.cer

更多信息请参阅此博客。


更新:
我们应该使用您的 CA 服务器的签名操作对 CertificateSignRequest 进行签名。

企业证书


如果您使用的是企业证书 解决方案,生成具有公用名值的客户端证书 格式为"name@yourdomain.com",而不是"域名\用户名" 格式。确保客户端证书基于"用户" 将"客户端身份验证"作为第一个的证书模板 使用列表中的项,而不是智能卡登录等。你可以检查 通过双击客户端证书并查看证书>增强型密钥用法的详细信息。

最新更新