powershell:“openssl x509 -in file.pem -text”相等的

发布于 2025-01-11 23:55:10 字数 163 浏览 5 评论 0原文

我一定使用了错误的查询,因为我找不到如何在 Powershell 中执行我使用简单操作所做的操作:

openssl x509 -in file.pem -text

我猜 Powershell 提供了本机命令来显示证书详细信息,但我正在努力寻找方法。

I must be using the wrong query because I cannot find how to do in Powershell what I do with a simple:

openssl x509 -in file.pem -text

I guess Powershell provides native commands to show certificate details but I'm struggling in finding how.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

自此以后,行同陌路 2025-01-18 23:55:10

[X509Certificate]:: CreateFromCertFile() 方法 本机读取 Base64 编码的 DER 证书文件,并在 Windows PowerShell 和更新版本中工作:

$certFile = Get-Item path\to\file.pem

$xCert2Type = [System.Security.Cryptography.X509Certificates.X509Certificate2]
$Certificate = $xCert2Type::CreateFromCertFile($certFile.FullName) -as $xCert2Type

显式转换为[X509Certificate2] 是经过深思熟虑的 - 它通过属性公开更多元数据,并在 PowerShell 中产生更好的默认输出格式

The [X509Certificate]::CreateFromCertFile() method reads Base64 encoded DER cert files natively and works in both Windows PowerShell and newer versions:

$certFile = Get-Item path\to\file.pem

$xCert2Type = [System.Security.Cryptography.X509Certificates.X509Certificate2]
$Certificate = $xCert2Type::CreateFromCertFile($certFile.FullName) -as $xCert2Type

The explicit conversion to [X509Certificate2] is deliberate - it exposes more metadata via properties and results in nicer default output formatting in PowerShell

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文