当前位置:网站首页 > 更多 > 玩电脑 > 正文

[玩转系统] PowerShell 获取 SSL 证书指纹

作者:精品下载站 日期:2024-12-14 22:00:58 浏览:11 分类:玩电脑

PowerShell 获取 SSL 证书指纹


在 PowerShell 中,使用与 ServicePoint.Certificate 关联的 GetCertHashString() 方法来获取 SSL 证书指纹或证书哈希值。

指纹或证书哈希是识别数字证书的唯一标识符。

在本文中,我们将讨论如何在 PowerShell 中查找 SSL 证书指纹或哈希值。

在 PowerShell 中查找网站的 SSL 证书指纹

在 PowerShell 中,使用 [Net.HttpWebRequest] 库创建与网站 URI 的连接。它检索有关 URI 的所有信息。

运行以下 PowerShell 脚本以获取 SSL 证书详细信息并检索网站的 SSL 证书指纹。

# Ignore SSL Warning
[Net.ServicePointManager]::ServerCertificateValidationCallback = { $true }

# Create Web Http request to URI
$uri = "https://google.com/" 
$webRequest = [Net.HttpWebRequest]::Create($uri)

# Get
$webRequest.ServicePoint

# Retrieve the Information for URI
$webRequest.GetResponse() | Out-NULL

# Get SSL Certificate and its details
$webRequest.ServicePoint.Certificate

# Get SSL Certificate Thumbprint
$webRequest.ServicePoint.Certificate.GetCertHashString()

在上面的 PowerShell 脚本中,它使用 [Net.HttpWebRequest] 创建对网站 URI 的 HTTP Web 请求,并在 $webRequest 变量。

$webRequest.GetResponse() 检索 URI 的响应并获取证书详细信息、服务器、标头和其他相关信息。

$webRequest.ServicePoint.Certificate 检索 SSL 证书详细信息。使用 GetCertHashString() 方法获取 SSL 证书指纹或证书哈希字符串值。

上述用于获取网站 SSL 证书哈希的 PowerShell 脚本的输出为:

[玩转系统] PowerShell 获取 SSL 证书指纹

酷提示:如何在 PowerShell 中检查 SSL 证书到期日期!

结论

希望上述关于如何在PowerShell中查找网站的SSL证书指纹的文章对您有所帮助。

您可以在 ShellGeek 主页上找到有关 PowerShell Active Directory 命令和 PowerShell 基础知识的更多主题。

您需要 登录账户 后才能发表评论

取消回复欢迎 发表评论:

关灯