有人能引导我从公钥中读取发行人吗?
我以前经常用下面的代码来做这件事。
$Cert = New-Object System.Security.Cryptography.X509Certificates.X509Certificate2
$cert.Import([Convert]::FromBase64String($KeyCred.key))
但它不再起作用了。
得到下面的错误。
MethodInvocationException: Exception calling "Import" with "1" argument(s):
"X509Certificate is immutable on this platform. Use the equivalent constructor instead."
我正在使用PowerShell 7,非常感谢您在这方面的帮助。
提前谢谢。
发布于 2022-05-26 08:50:21
如果您的$KeyCred.key
存储一个代表证书(不是公钥)的base64 64编码字符串,那么您可以使用如下适当的构造函数:
$cert = [Security.Cryptography.X509Certificates.X509Certificate2]::new([Convert]::FromBase64String($KeyCred.key))
https://stackoverflow.com/questions/72388852
复制相似问题