如何用powershell在在iis中创建csr证书


PowerShell交流中心如何用powershell在在iis中创建csr证书
0
gzj asked 7年 ago

iis中申请服务器证书需要先创建证书申请的csr文件,这一步用powershell这么实现,我在网上查的都是powershell做成自签证书的实例。

0 Answers
1
Mooser Lee 管理员 answered 7年 ago
# request模板
$requestInf= @'
;----------------- request.inf -----------------

[Version] 
Signature="$Windows NT$"

[NewRequest] 
;Change to your,country code, company name and common name 
Subject = "C=CN, O=Mosser Lee, CN=www.pstips.net"

KeySpec = 1 
KeyLength = 2048 
Exportable = TRUE 
MachineKeySet = TRUE 
SMIME = False 
PrivateKeyArchive = FALSE 
UserProtected = FALSE 
UseExistingKeySet = FALSE 
ProviderName = "Microsoft RSA SChannel Cryptographic Provider" 
ProviderType = 12 
RequestType = PKCS10 
KeyUsage = 0xa0

[EnhancedKeyUsageExtension] 
OID=1.3.6.1.5.5.7.3.1 ; this is for Server Authentication / Token Signing 
;-----------------------------------------------
'@

#输出模板到文件
$requestInfFile =  'request.inf'
$requestCSRFile = 'request.csr'
$requestInf | Out-File $requestInfFile

#创建证书
certreq -new $requestInfFile $requestCSRFile

#打印证书路径
$requestCSRFile = (Get-Item $requestCSRFile).FullName
Write-Host "CSR文件已保存到 $requestCSRFile"