Beispiel #1
0
        private void mnuProfileSettings_Click(object sender, EventArgs e)
        {
            using (frmSettings frm = new frmSettings(_node.Profile))
            {
                if (frm.ShowDialog(this) == DialogResult.OK)
                {
                    if (frm.PasswordChangeRequest)
                    {
                        _profile.ChangePassword(frm.Password);
                    }

                    _profile.DownloadFolder = frm.DownloadFolder;
                    _profile.TrackerURIs    = frm.Trackers;
                    _profile.LocalPort      = frm.Port;
                    _profile.CheckCertificateRevocationList   = frm.CheckCertificateRevocationList;
                    _profile.AllowInboundInvitations          = frm.AllowInboundInvitations;
                    _profile.AllowOnlyLocalInboundInvitations = frm.AllowOnlyLocalInboundInvitations;
                    _profile.EnableUPnP = frm.EnableUPnP;

                    if (frm.EnableProxy)
                    {
                        _profile.ConfigureProxy(frm.ProxyType, frm.ProxyAddress, frm.ProxyPort, frm.ProxyCredentials);
                    }
                    else
                    {
                        _profile.DisableProxy();
                    }

                    SaveProfile();

                    //set proxy
                    _updateClient.Proxy = _profile.Proxy;
                }
            }
        }
Beispiel #2
0
        private void RegisterAsync(CertificateProfile certProfile)
        {
            try
            {
                //register
                AsymmetricCryptoKey privateKey;

                if (rbImportRSA.Checked)
                {
                    privateKey = AsymmetricCryptoKey.CreateUsing(_parameters);
                }
                else
                {
                    privateKey = new AsymmetricCryptoKey(AsymmetricEncryptionAlgorithm.RSA, 4096);
                }

                Certificate selfSignedCert = new Certificate(CertificateType.RootCA, "", certProfile, CertificateCapability.SignCACertificate, DateTime.UtcNow, DateTime.UtcNow, AsymmetricEncryptionAlgorithm.RSA, privateKey.GetPublicKey());
                selfSignedCert.SelfSign("SHA256", privateKey, null);

                if (_profile == null)
                {
                    List <Uri> trackerURIs = new List <Uri>();

                    trackerURIs.AddRange(BitChatProfile.IPv4DefaultTrackerURIs);
                    trackerURIs.AddRange(BitChatProfile.IPv6DefaultTrackerURIs);

                    _profile = new BitChatProfile((new Random(DateTime.UtcNow.Millisecond)).Next(1024, 65535), Environment.GetFolderPath(Environment.SpecialFolder.Desktop), trackerURIs.ToArray(), _isPortableApp, _profileFolder);
                }

                if (_enableProxy)
                {
                    _profile.ConfigureProxy(_proxyType, _proxyAddress, _proxyPort, _proxyCredentials);
                }

                _profile.Register(Program.SIGNUP_URI, new CertificateStore(selfSignedCert, privateKey));
                _profile.SetPassword(SymmetricEncryptionAlgorithm.Rijndael, 256, txtProfilePassword.Text);

                _profileFilePath = Path.Combine(_profileFolder, _profile.LocalCertificateStore.Certificate.IssuedTo.Name + ".profile");

                using (FileStream fS = new FileStream(_profileFilePath, FileMode.Create, FileAccess.ReadWrite))
                {
                    _profile.WriteTo(fS);
                }

                this.Invoke(new Action <object>(RegistrationSuccess), new object[] { null });
            }
            catch (Exception ex)
            {
                this.Invoke(new Action <object>(RegistrationFail), new object[] { ex.Message });
            }
        }