示例#1
0
        private void MainForm_Shown(object sender, EventArgs e)
        {
            InitAI();
            TrackPageView(nameof(MainForm));

            this.VaultManager = new VaultManager(Properties.Settings.Default.VaultPath, LocalDiskVault.VAULT);

            if (!VaultManager.IsCompatiblePowershell())
            {
                MessageBox.Show("This application requires PowerShell version 4.0 or higher. You can update it using the latest Windows Management Framework download from Microsoft.", Properties.Resources.AppName);
                Application.Exit();
                return;
            }

            if (Properties.Settings.Default.ShowBetaWarning)
            {
                MessageBox.Show(Properties.Resources.BetaWarning, Properties.Resources.AppName);
            }

            /*if (this.VaultManager.IsValidVaultPath(Properties.Settings.Default.VaultPath))
             * {
             *  this.ReloadVault();
             * }*/
            var vaultInfo = VaultManager.GetVaultConfig();

            /*if (vaultInfo == null)
             * {
             *  LocateOrCreateVault(useDefaultCreationPath: false);
             *
             *  vaultInfo = VaultManager.GetVaultConfig();
             * }
             * else
             * {
             *  lblGettingStarted.Text = Properties.Resources.GettingStartedExistingVault;
             * }
             */

            if (vaultInfo != null && vaultInfo.Registrations == null)
            {
                //got an existing vault. If no contact registrations setup, prompt to add one
                var promptResult = MessageBox.Show("No certificate contact registrations have been setup. Add a new contact now? ", "Create New Contact?", MessageBoxButtons.YesNo);

                if (promptResult == DialogResult.Yes)
                {
                    ShowContactRegistrationDialog();
                }
            }
            ReloadVault();
        }
示例#2
0
        private void MainForm_Shown(object sender, EventArgs e)
        {
            InitAI();
            TrackPageView(nameof(MainForm));

            var powershellVersion = PowershellManager.GetPowershellVersion();

            if (powershellVersion < 4)
            {
                MessageBox.Show("This application requires PowerShell version 4.0 or higher. You can update it using the latest Windows Management Framework download from Microsoft.", Properties.Resources.AppName);

                Application.Exit();
                return;
            }

            this.VaultManager = new VaultManager(Properties.Settings.Default.VaultPath, LocalDiskVault.VAULT);

            PowershellManager manager = this.VaultManager.PowershellManager;

            /*if (!manager.IsAcmeSharpModuleInstalled())
             * {
             *  if (MessageBox.Show("The required PowerShell module 'ACMESharp' cannot be found. Please see https://www.powershellgallery.com/packages/ACMESharp/ or install from PowerShell command line as an administrator using: 'Install-Module -Name ACMESharp'",
             *          "ACMESharp Missing", MessageBoxButtons.OK, MessageBoxIcon.Error) == DialogResult.OK)
             *  {
             *      // Application.Exit();
             *  }
             * }*/

            if (Properties.Settings.Default.ShowBetaWarning)
            {
                this.lblGettingStarted.Text += "\r\n\r\n" + Properties.Resources.BetaWarning;
            }

            var vaultInfo = VaultManager.GetVaultConfig();

            if (vaultInfo != null && vaultInfo.Registrations == null)
            {
                //got an existing vault. If no contact registrations setup, prompt to add one
                var promptResult = MessageBox.Show("No certificate contact registrations have been setup. Would you like to add a new contact now? ", "Create New Contact?", MessageBoxButtons.YesNo);

                if (promptResult == DialogResult.Yes)
                {
                    ShowContactRegistrationDialog();
                }
            }
            ReloadVault();
        }
示例#3
0
        private void MainForm_Shown(object sender, EventArgs e)
        {
            InitAI();
            TrackPageView(nameof(MainForm));

            if (this.requirePowershell)
            {
                var powershellVersion = PowershellManager.GetPowershellVersion();
                if (powershellVersion < 4)
                {
                    MessageBox.Show("This application requires PowerShell version 4.0 or higher. You can update it using the latest Windows Management Framework download from Microsoft.", Properties.Resources.AppName);

                    Application.Exit();
                    return;
                }
            }

            this.VaultManager = new VaultManager(Properties.Settings.Default.VaultPath, LocalDiskVault.VAULT);

            if (Properties.Settings.Default.ShowBetaWarning)
            {
                // this.lblGettingStarted.Text += "\r\n\r\n" + Properties.Resources.BetaWarning;
            }

            var vaultInfo = VaultManager.GetVaultConfig();

            if (vaultInfo != null && vaultInfo.Registrations == null)
            {
                //got an existing vault. If no contact registrations setup, prompt to add one
                var promptResult = MessageBox.Show("No certificate contact registrations have been setup. Would you like to add a new contact now? ", "Create New Contact?", MessageBoxButtons.YesNo);

                if (promptResult == DialogResult.Yes)
                {
                    ShowContactRegistrationDialog();
                }
            }
            ReloadVault();
        }
示例#4
0
        private bool LocateOrCreateVault(bool useDefaultCreationPath = true)
        {
            var promptResult = MessageBox.Show("Do you want to create a new vault? Choose No to browse to an existing Vault folder.", "Change Vault", MessageBoxButtons.YesNoCancel);

            if (promptResult == DialogResult.Yes)
            {
                var useProductionPrompt = MessageBox.Show("Do you want to use the Live LetsEncrypt.org API? Choose No to use the staging (test) API for this vault.", Properties.Resources.AppName, MessageBoxButtons.YesNo);

                bool useStagingAPI = false;
                if (useProductionPrompt == DialogResult.No)
                {
                    useStagingAPI = true;
                }

                var useDefaultPath = MessageBox.Show("Do you want to use the default vault path of " + Properties.Settings.Default.DefaultVaultPath + "?", Properties.Resources.AppName, MessageBoxButtons.YesNo);
                if (useDefaultPath == DialogResult.Yes)
                {
                    useDefaultCreationPath = true;
                }

                string newVaultPath = Properties.Settings.Default.DefaultVaultPath;
                if (!useDefaultCreationPath)
                {
                    //browse to a follder to store vault in
                    var d            = new FolderBrowserDialog();
                    var dialogResult = d.ShowDialog();
                    if (dialogResult == DialogResult.OK)
                    {
                        newVaultPath = d.SelectedPath;
                    }
                    else
                    {
                        return(false);
                    }
                }

                if (Directory.Exists(newVaultPath) && Directory.GetFiles(newVaultPath).Any())
                {
                    MessageBox.Show("You need to create the vault in a new empty folder. The specified folder is not empty.");
                    return(false);
                }

                if (VaultManager.InitVault(useStagingAPI))
                {
                    //vault created

                    ReloadVault();
                    return(true);
                }
            }

            if (promptResult == DialogResult.No)
            {
                //folder picker browse to vault folder
                var d            = new FolderBrowserDialog();
                var dialogResult = d.ShowDialog();
                if (dialogResult == DialogResult.OK)
                {
                    if (VaultManager.IsValidVaultPath(d.SelectedPath))
                    {
                        VaultManager = new VaultManager(d.SelectedPath, LocalDiskVault.VAULT);
                        ReloadVault();
                        return(true);
                    }
                    else
                    {
                        MessageBox.Show("The selected folder is not a valid Vault.");
                        return(false);
                    }
                }
            }

            return(false);
        }