使用 Powershell 或命令提示符搜索通配符证书用法
Wildcard certificate usage search with Powershell or Command prompt
我有一个bash命令
curl -v --silent https://abc.xyz/ 2>&1 | grep "CN=\*.xyz.com" -c
这在 Ubuntu 机器上工作正常,但我想在 Powershell 或 CMD 中转换或使用类似的命令。我尝试了很多变体,例如:
curl https://abc.xyz/ 2>&1 | Select-String -Pattern "CN=\*.xyz.com"
curl -E -Uri https://abc.xyz/ 2>&1 | Select-String -Pattern "CN=\*.xyz.com"
Invoke-WebRequest https://abc.xyz/ 2>&1 | Select-String -Pattern "CN=\*.xyz.com"
我在 PS 命令中注意到的是,它没有输出通用名称来检查模式。
我的实际需要是检查 https://abc.xyz/
中是否使用了通配符证书。
我在这里错过了什么?
My actual need is to check if the wildcard cert used in https://abc.xyz/ or not.
在此示例中,我们将检查 msn.com:
上是否使用了通配符证书
$url = 'https://www.msn.com'
$req = [Net.HttpWebRequest]::Create($url)
$req.GetResponse() | Out-Null
$cerName = $req.ServicePoint.Certificate.GetName()
$cerName -match 'CN=\*\.msn\.com'
输出:
True
我有一个bash命令
curl -v --silent https://abc.xyz/ 2>&1 | grep "CN=\*.xyz.com" -c
这在 Ubuntu 机器上工作正常,但我想在 Powershell 或 CMD 中转换或使用类似的命令。我尝试了很多变体,例如:
curl https://abc.xyz/ 2>&1 | Select-String -Pattern "CN=\*.xyz.com"
curl -E -Uri https://abc.xyz/ 2>&1 | Select-String -Pattern "CN=\*.xyz.com"
Invoke-WebRequest https://abc.xyz/ 2>&1 | Select-String -Pattern "CN=\*.xyz.com"
我在 PS 命令中注意到的是,它没有输出通用名称来检查模式。
我的实际需要是检查 https://abc.xyz/
中是否使用了通配符证书。
我在这里错过了什么?
My actual need is to check if the wildcard cert used in https://abc.xyz/ or not.
在此示例中,我们将检查 msn.com:
上是否使用了通配符证书$url = 'https://www.msn.com'
$req = [Net.HttpWebRequest]::Create($url)
$req.GetResponse() | Out-Null
$cerName = $req.ServicePoint.Certificate.GetName()
$cerName -match 'CN=\*\.msn\.com'
输出:
True