(PowerShell) Transition from Cert.ExportPublicKey to Cert.GetPublicKey
Provides instructions for replacing deprecated ExportPublicKey method calls with GetPublicKey. Note: This example requires Chilkat v11.0.0 or greater.
Add-Type -Path "C:\chilkat\ChilkatDotNet47-x64\ChilkatDotNet47.dll"
$cert = New-Object Chilkat.Cert
# ------------------------------------------------------------------------
# The ExportPublicKey method is deprecated:
$publickeyObj = $cert.ExportPublicKey()
if ($cert.LastMethodSuccess -eq $false) {
$($cert.LastErrorText)
exit
}
# ...
# ...
# ------------------------------------------------------------------------
# Do the equivalent using GetPublicKey.
# Your application creates a new, empty PublicKey object which is passed
# in the last argument and filled upon success.
$publickeyOut = New-Object Chilkat.PublicKey
$success = $cert.GetPublicKey($publickeyOut)
if ($success -eq $false) {
$($cert.LastErrorText)
exit
}
|