PowerShell
PowerShell
Load Certificate from .cer and Private Key from .pem
See more Certificates Examples
Load a certificate from a .cer and its associated private key from a .pem.Chilkat PowerShell Downloads
Add-Type -Path "C:\chilkat\ChilkatDotNet47-x64\ChilkatDotNet47.dll"
$success = $false
$cert = New-Object Chilkat.Cert
$success = $cert.LoadFromFile("C:/certs_and_keys/Certificate.cer")
if ($success -eq $false) {
$($cert.LastErrorText)
exit
}
$sbPem = New-Object Chilkat.StringBuilder
$success = $sbPem.LoadFile("C:/certs_and_keys/PrivateKey.pem","utf-8")
if ($success -eq $false) {
$("Failed to load private key PEM")
exit
}
$success = $cert.SetPrivateKeyPem($sbPem.GetAsString())
if ($success -eq $false) {
$($cert.LastErrorText)
exit
}
$("The certificate and associated private key are now loaded and ready for signing.")