Xojo Plugin
Xojo Plugin
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 Xojo Plugin Downloads
Dim success As Boolean
success = False
Dim socket As New Chilkat.Socket
// Connect to the server using TLS.
Dim bTls As Boolean
bTls = True
Dim maxWaitMs As Int32
maxWaitMs = 5000
success = socket.Connect("example.com",5000,bTls,maxWaitMs)
If (success = False) Then
System.DebugLog(socket.LastErrorText)
Return
End If
// Copy the certificate presented by the remote TLS server, then inspect it. This can be used to
// validate the server's identity.
Dim cert As New Chilkat.Cert
success = socket.GetServerCert(cert)
If (success = False) Then
System.DebugLog(socket.LastErrorText)
Return
End If
System.DebugLog("Server certificate subject: " + cert.SubjectCN)
System.DebugLog("Issued by: " + cert.IssuerCN)