Created
July 17, 2023 18:28
-
-
Save spawnmarvel/90360dd85e6d9e14d807c3ecaf5d8e26 to your computer and use it in GitHub Desktop.
Check certificate
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
# modified | |
$fqdn = "xxxx.servicebus.windows.net" | |
$port = 443 | |
$tcpsocket = New-Object Net.Sockets.TcpClient($fqdn, $port) | |
$tcpstream = $tcpsocket.GetStream() | |
$sslStream = New-Object Net.Security.SslStream($tcpstream, $false) | |
$sslStream.AuthenticateAsClient($fqdn) | |
$certinfo = New-Object security.cryptography.x509certificates.x509certificate2($sslStream.RemoteCertificate) | |
# look at $tcpsocket.Client.RemoteEndPoint to see Server IP the client is using for connection | |
$certinfo | fl | |
$certinfo.Extensions | where {$_.Oid.FriendlyName -like 'subject alt*'} | ` foreach { $_.Oid.FriendlyName; $_.Format($true) } | |
$tcpsocket.Close() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment