我正在尝试创建具有特定加密参数值的自签名证书。
在运行 PowerShell 5.0 的 Win Server 2012 r2 标准上,当我尝试使用
New-SelfSignedCertificate
我收到一个错误:
New-SelfSignedCertificate:找不到与参数名称“主题”匹配的参数。
当我尝试使用该-Subject
参数时,除了笔记本电脑上允许的其他参数外,该参数不会出现在智能感知中。
但是在我的笔记本电脑(Win 10 和 PowerShell 5.0)上,我可以使用这些参数,并且我使用以下代码创建了一个自签名证书
#create a Certificate
# OID for document encryption
$Oid = New-Object System.Security.Cryptography.Oid "1.3.6.1.4.1.311.80.1"
$oidCollection = New-Object System.Security.Cryptography.OidCollection
$oidCollection.Add($oid) > $Null
# Create enhanced key usage extension that allows document encryption
$Ext = New-Object System.Security.Cryptography.X509Certificates.X509EnhancedKeyUsageExtension $oidCollection, $true
$myCert = New-SelfSignedCertificate -Subject 'CN=myservernameasubject' -CertStoreLocation "Cert:\LocalMachine\My" -KeySpec KeyExchange -KeyUsage KeyEncipherment, DataEncipherment -Extension $Ext