【问题标题】:How to remove Enhanced Key Usage using New-SelfSignedCertificate如何使用 New-SelfSignedCertificate 删除增强的密钥使用
【发布时间】:2020-11-22 10:48:23
【问题描述】:

运行以下命令后,扩展密钥使用/增强密钥使用显示客户端和服务器授权,我如何删除根 CA 和中间 CA 的此选项,因为 CA 不应该有这些选项。应该在 New-SelfSignedCertificate 中添加哪些其他参数以删除以下选项? 客户端身份验证 (1.3.6.1.5.5.7.3.2) 服务器身份验证 (1.3.6.1.5.5.7.3.1)

Windows 10 电源外壳 v5 openssl 1.1.1

$RootCA = New-SelfSignedCertificate -Subject 'CN=KeyCARootCN,O=Test Organisation, OU=Test RootCA,C=AU'  -KeyLength 2048 -KeyAlgorithm 'RSA' -HashAlgorithm 'SHA256' -KeyExportPolicy Exportable -KeyUsage KeyEncipherment,DataEncipherment,CertSign,DigitalSignature,CRLSign -Provider 'Microsoft Enhanced RSA and AES Cryptographic Provider' -NotAfter (Get-Date).AddYears(40) -KeyUsageProperty All -TextExtension @(“2.5.29.19 ={critical} {text}ca=1&pathlength=5”) -CertStoreLocation Cert:\LocalMachine\My
$RootCA
$RootCAthumbprint = $RootCA.Thumbprint


$CertRootCAPassword = ConvertTo-SecureString -String “Test123” -Force –AsPlainText
$CertRootCAFilePFX = Export-PfxCertificate -Cert cert:\LocalMachine\My\$RootCAthumbprint -FilePath C:\Users\KeyCARoot.pfx -Password $CertRootCAPassword

$CertRootCAFileCER = Export-Certificate -Cert $RootCA -FilePath C:\Users\KeyCARoot.cer

$CertRootCAFileCER
$CertRootCAPath = 'C:\Users\KeyCARoot.cer'

【问题讨论】:

    标签: powershell


    【解决方案1】:

    试试这个:

    Import-Module PKI
    
    $params = @{
        Type = [Microsoft.CertificateServices.Commands.CertificateType]::Custom
        Subject = 'CN=KeyCARootCN,O=Test Organisation, OU=Test RootCA,C=AU'
        KeyLength = 2048
        KeyAlgorithm = 'RSA'
        HashAlgorithm = [System.Security.Cryptography.HashAlgorithmName]::SHA256
        KeyExportPolicy = [Microsoft.CertificateServices.Commands.KeyExportPolicy]::Exportable
        KeySpec = [Microsoft.CertificateServices.Commands.KeySpec]::Signature
        KeyUsage = @([Microsoft.CertificateServices.Commands.KeyUsage]::CertSign,
            [Microsoft.CertificateServices.Commands.KeyUsage]::DigitalSignature,
            [Microsoft.CertificateServices.Commands.KeyUsage]::CRLSign)
        KeyUsageProperty = [Microsoft.CertificateServices.Commands.KeyUsageProperty]::All
        TextExtension = @('2.5.29.19={critical}{text}ca=1&pathlength=5')
        NotAfter = (Get-Date).AddYears(40)
        Provider = 'Microsoft Enhanced Cryptographic Provider v1.0'
        CertStoreLocation = 'Cert:\LocalMachine\My'
    }
    
    $RootCA = New-SelfSignedCertificate @params
    

    一般来说,您可能过度指定了一些不必要的选项。从上面可以看出,我只是添加了一个Custom 证书类型,删除了KeyEnciphermentDataEncipherment 密钥使用选项,并换掉了CSP 提供程序。保留密钥使用的所有签名选项应该足以满足根证书和中间 CA 证书。

    如果您希望增强型密钥使用为“任何目的”,您可以将,'2.5.29.37={text}2.5.29.37.0' 添加到您的TextExtension 列表中。

    【讨论】:

      猜你喜欢
      • 2021-02-25
      • 1970-01-01
      • 2017-12-06
      • 1970-01-01
      • 1970-01-01
      • 2015-09-07
      • 2010-11-19
      • 1970-01-01
      • 2015-11-13
      相关资源
      最近更新 更多