Esempio n. 1
0
        static void Main(string[] args)
        {
            Common.LoggerFactory.Initialize();
            _logger = Common.LoggerFactory.GetLogger(typeof(Program));

            int port;

            if (args != null && args.Length == 3 &&
                !string.IsNullOrEmpty(args[0]) &&
                int.TryParse(args[1], out port) &&
                !string.IsNullOrEmpty(args[2]))
            {
                string serverName      = args[0];
                string certificateFile = args[2];

                _logger.InfoFormat("Connecting server: '{0}'; port: '{1}', certificate file: '{2}'.",
                                   serverName, port, certificateFile);


                using (SslTcpClient client = new SslTcpClient(serverName, port, certificateFile))
                {
                    client.Connect();
                }
            }
            else
            {
                ShowUsage();
            }
        }
Esempio n. 2
0
        //private
        public void ScreenSaver_Load(object sender, EventArgs e)
        {
            this.FormBorderStyle = FormBorderStyle.None;
            this.WindowState     = FormWindowState.Maximized;
            this.StartPosition   = FormStartPosition.Manual;
            this.TopMost         = true;
            //UpdateRegistry("Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\System", 0, "DisableTaskMgr", Registry.CurrentUser);
            pictureBox1.SizeMode = PictureBoxSizeMode.StretchImage;
            pictureBox1.Left     = (this.ClientSize.Width - pictureBox1.Width) / 2;
            pictureBox1.Top      = (this.ClientSize.Height - pictureBox1.Height) / 2 - 100;
            groupBox1.Left       = (this.ClientSize.Width - groupBox1.Width) / 2;

            nScreenSaverFlag = 1;
            nScreenSaver     = 0;
            if (i++ > 0)
            {
                string strLog;
                strLog = id + "α" +
                         NetworkInterface.GetAllNetworkInterfaces()[0].GetPhysicalAddress().ToString() +
                         "α" + "2" +
                         "α" + Get_MyIP();
                SslTcpClient.logWrite(strLog);

                //SslTcpClient.logWrite();
            }
        }
Esempio n. 3
0
 private void btnStop_Click(object sender, EventArgs e)
 {
     SetButtonEnabled(btnStop, false);
     _Client.Close();
     _Client = null;
     SetButtonEnabled(btnStart, true);
 }
Esempio n. 4
0
        private static int RunMain(String clientCommand)
        {
            // connection to server
            SslStream serverConnection = SslTcpClient.RunClient();

            // test connection
            if (serverConnection == null)
            {
                return(2);
            }

            // ask for nonce
            Boolean nonceRequest = SslTcpClient.RequestNonce(serverConnection);

            // test nonce request
            if (!nonceRequest)
            {
                return(3);
            }

            String nonce = GetUserSecurity.GetUserNonce();

            // ask for command
            Boolean commandRequest = SslTcpClient.RequestCommand(serverConnection, clientCommand, nonce);

            // test command request
            if (!commandRequest)
            {
                return(4);
            }

            // get command response
            Boolean commandResponse = SslTcpClient.GetCommandResponse(serverConnection);

            // test command response
            if (!commandResponse)
            {
                return(5);
            }

            return(0);
        }
Esempio n. 5
0
        private void Button_Confirm_Click(object sender, EventArgs e)
        {
            SslTcpClient.RunClient("15.164.170.79", "DESKTOP-NHIE464\\kkh", textBox1.Text, textBox2.Text, requestvalue);

            //접속 서버 IP, 인증서 유효성 검사를 위한 인증서의 발급자 정보, 서버로 전송할 ID값, PWS값, 서버에서 로그인 여부를 저장할 bool변수
            if (SslTcpClient.IsSuccess)
            {
                vipdata = SslTcpClient.buf;
                UpdatePolicy();
                id       = textBox1.Text;
                password = textBox2.Text;

                string strLog;
                strLog = id + "α" +
                         NetworkInterface.GetAllNetworkInterfaces()[0].GetPhysicalAddress().ToString() +
                         "α" + "1" +
                         "α" + Get_MyIP();
                SslTcpClient.logWrite(strLog);

                this.Close();
            }
        }
Esempio n. 6
0
 private void btnStart_Click(object sender, EventArgs e)
 {
     if (_Client == null)
     {
         string cer = txtCer.Text;
         if (string.IsNullOrEmpty(System.IO.Path.GetDirectoryName(cer)))
         {
             cer = System.IO.Path.Combine(Environment.CurrentDirectory, "Web", cer);
         }
         System.Security.Cryptography.X509Certificates.X509Certificate cert =
             System.Security.Cryptography.X509Certificates.X509Certificate.CreateFromCertFile(cer);
         SslTcpClient.BypassIssuer = cert.Issuer;
         _Client                   = SslTcpClient.ConnectTo(new IPEndPoint(IPAddress.Parse(txtIP.Text), Convert.ToInt32(txtPort.Text)), cer);
         _Client.Connected        += new EventHandler <SslTcpEventArgs>(Client_OnConnected);
         _Client.Closed           += new EventHandler <SslTcpEventArgs>(Client_OnClosed);
         _Client.DataReceived     += new EventHandler <SslTcpEventArgs>(Client_OnDataReceived);
         _Client.DataSended       += new EventHandler <SslTcpEventArgs>(Client_OnDataSended);
         _Client.AuthenticateFail += new EventHandler <SslTcpEventArgs>(Client_AuthenticateFail);
     }
     btnStart.Enabled = false;
     btnStop.Enabled  = true;
 }
Esempio n. 7
0
            public static int Main(string[] args)
            {
                string serverCertificateName = @"c:\work\privateKey.key";
                string machineName           = "127.0.0.1";

                //if (args == null || args.Length < 1)
                //{
                //    DisplayUsage();
                //}
                //// User can specify the machine name and server name.
                //// Server name must match the name on the server's certificate.
                //machineName = args[0];
                //if (args.Length < 2)
                //{
                //    serverCertificateName = machineName;
                //}
                //else
                //{
                //    serverCertificateName = args[1];
                //}
                SslTcpClient.RunClient(machineName, serverCertificateName);
                return(0);
            }
Esempio n. 8
0
 private void ScreenSaver_FormClosing(object sender, FormClosingEventArgs e)
 {
     nScreenSaverFlag = 0;
     SslTcpClient.CloseHandle();
 }