AutoIt
AutoIt
Get the Server Certificate from a TLS Connection
See more Socket/SSL/TLS Examples
Demonstrates Socket.GetServerCert, which copies the certificate presented by the remote TLS server into a Cert object for inspection.
Background. The method returns false when the socket is not connected, is not using TLS, or no server certificate is available. Inspecting the certificate lets an application validate the server's identity.
Chilkat AutoIt Downloads
Local $bSuccess = False
$oSocket = ObjCreate("Chilkat.Socket")
; Connect to the server using TLS.
Local $bTls = True
Local $iMaxWaitMs = 5000
$bSuccess = $oSocket.Connect("example.com",5000,$bTls,$iMaxWaitMs)
If ($bSuccess = False) Then
ConsoleWrite($oSocket.LastErrorText & @CRLF)
Exit
EndIf
; Copy the certificate presented by the remote TLS server, then inspect it. This can be used to
; validate the server's identity.
$oCert = ObjCreate("Chilkat.Cert")
$bSuccess = $oSocket.GetServerCert($oCert)
If ($bSuccess = False) Then
ConsoleWrite($oSocket.LastErrorText & @CRLF)
Exit
EndIf
ConsoleWrite("Server certificate subject: " & $oCert.SubjectCN & @CRLF)
ConsoleWrite("Issued by: " & $oCert.IssuerCN & @CRLF)