powershell - 如何使用 Powershell 从 PFX 证书获取公钥?

标签 powershell certificate public-key pkcs12

我正在尝试使用 Powershell 从证书中提取公钥。但是,每当我使用 Powershell 命令时 Get-PfxCertificate它只输出证书的指纹而不是公钥。我怎样才能让它输出公钥?

最佳答案

要使用 Powershell 从 PFX 证书中检索公钥,请使用以下命令:

(Get-PfxCertificate -FilePath mycert.pfx).GetPublicKey()

要将公钥转换为不带连字符的十六进制字符串,您可以使用以下命令:
[System.BitConverter]::ToString((Get-PfxCertificate -FilePath mycert.pfx).GetPublicKey()).Replace("-", "")

关于powershell - 如何使用 Powershell 从 PFX 证书获取公钥?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38134750/

相关文章:

encryption - 如何从私钥生成RSA公钥?

csv - 如何在多个CSV文件中比较,匹配和附加多个值?

powershell - 如何从我所在的同一文件夹中调用文件(在脚本中)

powershell - 如何使用powershell读取CSV文件的第一列

iphone - 带 NSURLConnection 的 HTTPS - NSURLErrorServerCertificateUntrusted

iis - HTTP 错误 403.16 - 客户端证书信任问题

ssl - 如何格式化 openssl.cnf 文件中的 OID Subject Alt Name 条目

powershell - 使用 Powershell 确定 Internet 连接

javascript - 从 .env 文件访问 .pem 公钥

git - gerrit setup git repo——权限被拒绝