Sample code for 30+ languages & platforms
AutoIt

Verify SSL Server Certificate

See more Socket/SSL/TLS Examples

Demonstrates how to connect to an SSL server and verify its SSL certificate.

Chilkat AutoIt Downloads

AutoIt
Local $bSuccess = False

; This example requires the Chilkat API to have been previously unlocked.
; See Global Unlock Sample for sample code.

$oSocket = ObjCreate("Chilkat.Socket")

Local $bSsl = True
Local $iMaxWaitMillisec = 20000

; The SSL server hostname may be an IP address, a domain name,
; or "localhost". 
Local $sslServerHost
$sslServerHost = "www.paypal.com"
Local $iSslServerPort = 443

; Connect to the SSL server:
$bSuccess = $oSocket.Connect($sslServerHost,$iSslServerPort,$bSsl,$iMaxWaitMillisec)
If ($bSuccess = False) Then
    ConsoleWrite($oSocket.LastErrorText & @CRLF)
    Exit
EndIf

$oCert = ObjCreate("Chilkat.Cert")

Local $bExpired
Local $bRevoked
Local $bSignatureVerified
Local $bTrustedRoot

$bSuccess = $oSocket.GetServerCert($oCert)
If ($bSuccess <> False) Then

    ConsoleWrite("Server Certificate:" & @CRLF)
    ConsoleWrite("Distinguished Name: " & $oCert.SubjectDN & @CRLF)
    ConsoleWrite("Common Name: " & $oCert.SubjectCN & @CRLF)
    ConsoleWrite("Issuer Distinguished Name: " & $oCert.IssuerDN & @CRLF)
    ConsoleWrite("Issuer Common Name: " & $oCert.IssuerCN & @CRLF)

    $bExpired = $oCert.Expired
    $bRevoked = $oCert.Revoked
    $bSignatureVerified = $oCert.SignatureVerified
    $bTrustedRoot = $oCert.TrustedRoot

    ConsoleWrite("Expired: " & $bExpired & @CRLF)
    ConsoleWrite("Revoked: " & $bRevoked & @CRLF)
    ConsoleWrite("Signature Verified: " & $bSignatureVerified & @CRLF)
    ConsoleWrite("Trusted Root: " & $bTrustedRoot & @CRLF)

EndIf

; Close the connection with the server
; Wait a max of 20 seconds (20000 millsec)
$bSuccess = $oSocket.Close(20000)