支持所有版本。
通常從文件加載一個(gè)證書并且安裝它到指定的庫??梢允褂孟旅娴哪_本:
復(fù)制代碼 代碼如下:
$pfxpath = 'C:\temp\test.pfx'
$password = 'test'
[System.Security.Cryptography.X509Certificates.StoreLocation]$Store = 'CurrentUser'
$StoreName = 'root'
Add-Type -AssemblyName System.Security
$certificate = New-Object System.Security.Cryptography.X509Certificates.X509Certificate2
$certificate.Import($pfxpath, $password, 'Exportable')
$Store = New-Object system.security.cryptography.X509Certificates.x509Store($StoreName, $StoreLocation)
$Store.Open('ReadWrite')
$Store.Add($certificate)
$Store.Close()
現(xiàn)在你可以配置這個(gè)腳本,指定證書的位置和密碼。你還可以指定存儲位置(當(dāng)前用戶或本地計(jì)算機(jī))并添加證書(例如被信任的根證書)或私有證書。