Walkthroughs > Set up Secure Connections > Convert from Telnet to SSL/TLS |
You can set up applications that automatically convert Telnet sessions to secure sessions. This sample shows how to convert an IBM terminal session that is configured to connect through telnet to an SSL/TLS connection when its session document file is opened.
The sample only converts sessions that have a specific host address.
Convert Telnet to SSL/TLS |
Copy Code
|
---|---|
using System; using Attachmate.Reflection.Framework; using Attachmate.Reflection.Emulation.IbmHosts; using Attachmate.Reflection.UserInterface; namespace CreateSessionFromExistingSessionFile { class Program { //Change these placeholders for your host static string yourHostName = "yourHostName"; static string yourDomainName = "yourdomain.com"; static int yourPort = 723; //Replace with your port static public void frame_View_Opened(object sender, EventArgs args) { IFrame frame = (IFrame)sender; IView view; //wait for the view while ((view = frame.SelectedView) == null) { System.Threading.Thread.Sleep(500); } //check for the IbmTerminal type if (view.Control.ToString() == "Attachmate.Reflection.Emulation.IbmHosts.IbmTerminal") { IIbmTerminal terminal = (IIbmTerminal)view.Control; //Disconnect and disable autoconnect so we can change security settings if (terminal.IsConnected == true) { terminal.AutoConnect = false; terminal.Disconnect(); } //Only change security for sessions that connect to your host if (terminal.EnableTelnetEncryption == false && terminal.HostAddress.Trim().ToUpper().Substring(0, yourHostName.Length) == yourHostName.ToUpper()) { terminal.EnableTelnetEncryption = true; terminal.TelnetEncryptionVerifyHostName = false; terminal.TelnetEncryptionDisableCRLCheck = true; terminal.HostAddress = yourHostName + "." + yourDomainName; terminal.Port = yourPort; } terminal.Connect(); } } static void Main(string[] args) { //Start a visible instance of InfoConnect or get the instance running at the given channel name Application app = MyReflection.CreateApplication("myWorkspace", true); IFrame frame = (IFrame)app.GetObject("Frame"); //Handle the ViewOpened event to make sure the connection uses SSL/TLS frame.ViewOpened += new ViewEventHandler(frame_View_Opened); Console.ReadKey(); } } } |