Last active
February 20, 2025 14:33
-
-
Save tcartwright/1cda5676a81a4cad49c1e33c4897c3eb to your computer and use it in GitHub Desktop.
POWERSHELL: Test https cert
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Clear-Host | |
$hostName = "www.microsoft.com" | |
$req = [System.Net.HttpWebRequest]::Create("https://$hostName") | |
$req.GetResponse().Dispose() | |
[System.Security.Cryptography.X509Certificates.X509Certificate2]$cert = $req.ServicePoint.Certificate | |
#$cert | Format-List * | |
$props = $cert | Select-Object Subject, | |
@{Name="ValidFrom"; Expression={$_.NotBefore}}, | |
@{Name="ValidTo"; Expression={$_.NotAfter}}, | |
@{Name="IsValid"; Expression={$_.Verify() -and (Get-Date) -le ([DateTime]::Parse($_.GetExpirationDateString())) }}, | |
@{Name="Encryption"; Expression={$_.SignatureAlgorithm.FriendlyName}}, | |
@{Name="DnsNames"; Expression={$_.DnsNameList.Unicode}}, | |
Issuer | |
$props | Out-Host |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment