Example: inspecting SSL session properties

The Visual Basic fragment below prints a description of the SSL session in which a SesssionManager::Session proxy was created:

Public Function SessionDetails( _
  title As String, _
  obj As JaguarTypeLibary.Object _
  )
   Me.Caption = title
   Call clearOutput
   output (title & ":" & vbCrLf)
   Dim sslSess As CtsSecurity.SSLSession
   Dim sslSessInfo As CtsSecurity.SSLSessionInfo
   Dim host, port, prop As String
   Dim inError As Boolean
   inError = False
   
   On Error GoTo errorGetSession
   Set sslSess = obj.Narrow_("CtsSecurity/SSLSession")
   Set sslSessInfo = sslSess. _
     getSessionInfo.Narrow_("CtsSecurity/SSLSessionInfo")
   
   On Error GoTo errorGetProperties
   host = sslSessInfo.getProperty("host")
   port = sslSessInfo.getProperty("port")
   
   output ("Connected to " & host & ":" & port & vbCrLf)
     
   prop = sslSessInfo.getProperty("cipherSuite")
   output ("Negotiated CipherSuite: " & prop & vbCrLf)
    
   ' Print the server certificate details
   On Error GoTo errorGetServerCert
   Dim cert As CtsSecurity.X509Certificate
   Set cert = sslSessInfo.getPeerCertificate().Narrow_("CtsSecurity/X509Certificate")
   output (vbCrLf & "Server certificate info:" & vbCrLf)
   output (certInfo(cert))
     
   ' Print the client certificate details
   On Error GoTo errorGetClientCert
   Set cert = sslSessInfo.
      getCertificate().Narrow_("CtsSecurity/X509Certificate")
   output (vbCrLf & "Personal certificate info:" & vbCrLf)
     
   output (certInfo(cert))
   inError = True ' Fall through error cases
' Error handling code. Labels are in reverse order of the
' On Error activations.
' Code to handle errors when retrieving the client certificate.
' Sessions will not have a client certificate unless mutual 
' authentication is used. So, this is not necessarily an error.
errorGetClientCert:
   If Not inError Then
     inError = True
     output (vbCrLf & "No personal certificate in use." & vbCrLf)
   End If
' Code to handle errors raised when getting the server certificate.
' If a connection uses SSL, it should at least have a server certificate,
' so errors raised are likely due to coding errors.
errorGetServerCert:
   If Not inError Then
     inError = True
      output (vbCrLf & "** Error retrieving server certificate properties. **" _
         & vbCrLf)
   End If
' Code for errors raised when retrieving session properties. Any error
' raised is likely due to a coding error.
errorGetProperties:
   If Not inError Then
      inError = True
      output ("Error retrieving SSL session properties." & vbCrLf)
   End If
' Code for errors raised when retrieving the session information.
' Errors here most likely mean that the connection does not use SSL.
errorGetSession:
   If Not inError Then
      inError = True
      output ("SSL not used on this connection.")
   End If
   
   ' All error handlers must fall through to here.
   Me.Show
    
End Function