Sample code for 30+ languages & platforms
AutoIt

Get a Received Client Certificate (Server Side)

See more Socket/SSL/TLS Examples

Demonstrates Socket.GetRcvdClientCert, which copies a client certificate presented during the TLS handshake of an accepted server-side connection into a Cert object.

The file path is relative to the application's current working directory. An absolute path may also be used. Supply the path appropriate to your own environment.

Background. Use NumReceivedClientCerts to determine the valid index range. Client certificates are supplied only when the server requests them for mutual TLS.

Chilkat AutoIt Downloads

AutoIt
Local $bSuccess = False

$oSocket = ObjCreate("Chilkat.Socket")

;  The file path is relative to the application's current working directory.  An absolute path
;  may also be used.  Supply the path appropriate to your own environment.
;  The PFX password should come from a secure source rather than being hard-coded.
Local $sPfxPassword = "myPfxPassword"
$oCert = ObjCreate("Chilkat.Cert")
$bSuccess = $oCert.LoadPfxFile("qa_data/server.pfx",$sPfxPassword)
If ($bSuccess = False) Then
    ConsoleWrite($oCert.LastErrorText & @CRLF)
    Exit
EndIf

$bSuccess = $oSocket.InitSslServer($oCert)
If ($bSuccess = False) Then
    ConsoleWrite($oSocket.LastErrorText & @CRLF)
    Exit
EndIf

$bSuccess = $oSocket.BindAndListen(5000,25)
If ($bSuccess = False) Then
    ConsoleWrite($oSocket.LastErrorText & @CRLF)
    Exit
EndIf

;  Accept a client connection.  The accepted connection carries any client certificate presented
;  during the TLS handshake.
$oConnectedSock = ObjCreate("Chilkat.Socket")
$bSuccess = $oSocket.AcceptNext(20000,$oConnectedSock)
If ($bSuccess = False) Then
    ConsoleWrite($oSocket.LastErrorText & @CRLF)
    Exit
EndIf

;  Copy each received client certificate and inspect it.
Local $iNumClientCerts = $oConnectedSock.NumReceivedClientCerts
$oClientCert = ObjCreate("Chilkat.Cert")
Local $i
For $i = 0 To $iNumClientCerts - 1
    $bSuccess = $oConnectedSock.GetRcvdClientCert($i,$oClientCert)
    If ($bSuccess = False) Then
        ConsoleWrite($oConnectedSock.LastErrorText & @CRLF)
        Exit
    EndIf

    ConsoleWrite("Client certificate subject: " & $oClientCert.SubjectCN & @CRLF)
Next