(PowerShell) ZATCA Load Certificate and Private Key from PEM Files
Demonstrates how to load a certificate and private key from a pair of PEM files.
Add-Type -Path "C:\chilkat\ChilkatDotNet47-9.5.0-x64\ChilkatDotNet47.dll"
# The LoadFromFile method will automatically detect the file format..
$cert = New-Object Chilkat.Cert
$success = $cert.LoadFromFile("qa_data/zatca/cert.pem")
if ($success -ne $true) {
$($cert.LastErrorText)
exit
}
$($cert.SubjectCN)
# Load the private key.
$privKey = New-Object Chilkat.PrivateKey
$success = $privKey.LoadPemFile("qa_data/zatca/ec-secp256k1-priv-key.pem")
if ($success -ne $true) {
$($privKey.LastErrorText)
exit
}
$("Key Type: " + $privKey.KeyType)
# Associate the private key with the certificate.
$success = $cert.SetPrivateKey($privKey)
if ($success -ne $true) {
$($cert.LastErrorText)
exit
}
$("Success.")
|