Reflection Desktop VBA Guide
HowTos / Handle TLS Authentication
In This Topic
    Handle TLS Authentication
    In This Topic

    You can use macros to configure Transport Layer Security (TLS) connections.

    This sample shows how to automatically convert telnet sessions that connect to a specific host to secure TLS connections when the sessions are opened.

    This sample applies only to IBM terminals

     To run this sample

    1. Open an IBM session in Reflection and then open the Visual Basic Editor.
    2. Select the Common project folder, and then open the Reflection Objects folder.
    3. Copy the following code into the ThisFrame code window.
    Convert a Telnet Session to TLS
    Copy Code
            
    Private Sub Frame_ViewOpened(ByVal sender As Variant, ByVal view As Attachmate_Reflection_Objects.view)
        Dim terminal As Attachmate_Reflection_Objects_Emulation_IbmHosts.ibmTerminal
        Dim HostAddress As String
       
        'Apply security only to IbmTerminal (IBM3270 or IBM5250) sessions
        If TypeName(view.control) = "IbmTerminal" Then
      
            Set terminal = view.control
            HostAddress = terminal.HostAddress
         
            With terminal
                'If security is not enabled and the host name starts with XYZ, change to a secure session
                If .EnableTelnetEncryption = False And Left(UCase(Trim(HostAddress)), 3) = "XYZ" Then
                   
                    'Make sure the terminal is disconnected before changing settings
                    If .IsConnected = True Then
                    .Disconnect
                    End If
                   
                    .EnableTelnetEncryption = True
                    .TLS_SSLVersion = TLSSSLVersionOption_TLS_V1_2
    
                    'Specify that the host name in the certificate must match the name of the host you are connecting to
                    .TelnetEncryptionVerifyHostName = True
    
                    'You may need to set additional properties to connect, depending on your host configuration.
                    'For example, you may need to select a set of custom ciphers in the Security Properties dialog box
                    'and then specify to use them as shown below
                   
                    '.TelnetEncryptionStrength = TelnetEncryptionStrengthOption_Custom
    
                    .HostAddress = "xyz.exampleDomain.com"
                    .Port = 723
                   
                    'Connect after changing the settings
                    .Connect
                   
                End If
            End With
             
        End If
    End Sub
    

    1. Replace the XYZ placeholder with your host name and change the value in the Trim function from 3 to the length of your host name. Then replace the placeholders for the HostAddress and Port properties with your host name and its secure port.
    2. Select File and then Save Common to save the macro.
    3. Back in the Reflection user interface, open an IBM session that is configured to connect through Telnet to the host name you entered in the code.
      The session is converted to a TLS session.

     

     

     

    See Also