Skip to content

Instantly share code, notes, and snippets.

@spawnmarvel
Created July 17, 2023 18:28
Show Gist options
  • Save spawnmarvel/90360dd85e6d9e14d807c3ecaf5d8e26 to your computer and use it in GitHub Desktop.
Save spawnmarvel/90360dd85e6d9e14d807c3ecaf5d8e26 to your computer and use it in GitHub Desktop.
Check certificate
# 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