Exemplo n.º 1
0
        private void InitializeServer()
        {
            X509Certificate2 serverCertificate;

#if DEBUG
            serverCertificate = CertificateHelper.CreateCertificateAuthority("Quasar Server CA", 2048);
#else
            if (!File.Exists(Settings.CertificatePath))
            {
                using (var certificateSelection = new FrmCertificate())
                {
                    while (certificateSelection.ShowDialog() != DialogResult.OK)
                    {
                    }
                }
            }
            serverCertificate = new X509Certificate2(Settings.CertificatePath, Settings.CertificatePassword);
#endif
            ListenServer                     = new QuasarServer(serverCertificate);
            ListenServer.ServerState        += ServerState;
            ListenServer.ClientConnected    += ClientConnected;
            ListenServer.ClientDisconnected += ClientDisconnected;
        }
Exemplo n.º 2
0
        private void InitializeServer()
        {
            X509Certificate2 serverCertificate;

#if DEBUG
            serverCertificate = CertificateHelper.CreateCertificateAuthority("Quasar Server CA", 2048);
#else
            if (!File.Exists(Settings.CertificatePath))
            {
                using (var certificateSelection = new FrmCertificate())
                {
                    while (certificateSelection.ShowDialog() != DialogResult.OK)
                    {
                    }
                }
            }
            serverCertificate = new X509Certificate2(Settings.CertificatePath);
#endif

            /*var str = Convert.ToBase64String(serverCertificate.Export(X509ContentType.Cert));
             *
             * var cert2 = new X509Certificate2(Convert.FromBase64String(str));
             * var serverCsp = (RSACryptoServiceProvider)serverCertificate.PublicKey.Key;
             * var connectedCsp = (RSACryptoServiceProvider)new X509Certificate2(cert2).PublicKey.Key;
             *
             * var result = serverCsp.ExportParameters(false);
             * var result2 = connectedCsp.ExportParameters(false);
             *
             * var b = SafeComparison.AreEqual(result.Exponent, result2.Exponent) &&
             *      SafeComparison.AreEqual(result.Modulus, result2.Modulus);*/

            ListenServer                     = new QuasarServer(serverCertificate);
            ListenServer.ServerState        += ServerState;
            ListenServer.ClientConnected    += ClientConnected;
            ListenServer.ClientDisconnected += ClientDisconnected;
        }
Exemplo n.º 3
0
        private void InitializeServer()
        {
            X509Certificate2 serverCertificate;

#if DEBUG
            serverCertificate = CertificateHelper.CreateCertificateAuthority("Quasar Server CA", 2048);
#else
            string certificatePath = Path.Combine(Application.StartupPath, "quasar.p12");
            if (!File.Exists(certificatePath))
            {
                using (var certificateSelection = new FrmCertificate())
                {
                    while (certificateSelection.ShowDialog() != DialogResult.OK)
                    {
                    }
                }
            }
            serverCertificate = new X509Certificate2(certificatePath);
#endif
            ListenServer                     = new QuasarServer(serverCertificate);
            ListenServer.ServerState        += ServerState;
            ListenServer.ClientConnected    += ClientConnected;
            ListenServer.ClientDisconnected += ClientDisconnected;
        }