mirror of
https://github.com/bitwarden/server.git
synced 2025-02-22 02:51:33 +01:00
Add install-id, install-key, and skip-ssl flags to Setup Project (#1260)
* Add install-id, install-key, and skip-ssl flags * Update util/Setup/CertBuilder.cs Co-authored-by: Kyle Spearrin <kspearrin@users.noreply.github.com> * Update util/Setup/Program.cs Co-authored-by: Kyle Spearrin <kspearrin@users.noreply.github.com> * Remove redundant variable assignment Co-authored-by: Kyle Spearrin <kspearrin@users.noreply.github.com>
This commit is contained in:
parent
79f3dabaac
commit
0366c0efef
@ -28,27 +28,32 @@ namespace Bit.Setup
|
||||
|
||||
if (!_context.Config.Ssl)
|
||||
{
|
||||
_context.Config.Ssl = Helpers.ReadQuestion("Do you have a SSL certificate to use?");
|
||||
if (_context.Config.Ssl)
|
||||
var skipSSL = _context.Parameters.ContainsKey("skip-ssl") && (_context.Parameters["skip-ssl"] == "true" || _context.Parameters["skip-ssl"] == "1");
|
||||
|
||||
if (!skipSSL)
|
||||
{
|
||||
Directory.CreateDirectory($"/bitwarden/ssl/{_context.Install.Domain}/");
|
||||
var message = "Make sure 'certificate.crt' and 'private.key' are provided in the \n" +
|
||||
"appropriate directory before running 'start' (see docs for info).";
|
||||
Helpers.ShowBanner(_context, "NOTE", message);
|
||||
}
|
||||
else if (Helpers.ReadQuestion("Do you want to generate a self-signed SSL certificate?"))
|
||||
{
|
||||
Directory.CreateDirectory($"/bitwarden/ssl/self/{_context.Install.Domain}/");
|
||||
Helpers.WriteLine(_context, "Generating self signed SSL certificate.");
|
||||
_context.Config.Ssl = true;
|
||||
_context.Install.Trusted = false;
|
||||
_context.Install.SelfSignedCert = true;
|
||||
Helpers.Exec("openssl req -x509 -newkey rsa:4096 -sha256 -nodes -days 36500 " +
|
||||
$"-keyout /bitwarden/ssl/self/{_context.Install.Domain}/private.key " +
|
||||
$"-out /bitwarden/ssl/self/{_context.Install.Domain}/certificate.crt " +
|
||||
$"-reqexts SAN -extensions SAN " +
|
||||
$"-config <(cat /usr/lib/ssl/openssl.cnf <(printf '[SAN]\nsubjectAltName=DNS:{_context.Install.Domain}\nbasicConstraints=CA:true')) " +
|
||||
$"-subj \"/C=US/ST=California/L=Santa Barbara/O=Bitwarden Inc./OU=Bitwarden/CN={_context.Install.Domain}\"");
|
||||
_context.Config.Ssl = Helpers.ReadQuestion("Do you have a SSL certificate to use?");
|
||||
if (_context.Config.Ssl)
|
||||
{
|
||||
Directory.CreateDirectory($"/bitwarden/ssl/{_context.Install.Domain}/");
|
||||
var message = "Make sure 'certificate.crt' and 'private.key' are provided in the \n" +
|
||||
"appropriate directory before running 'start' (see docs for info).";
|
||||
Helpers.ShowBanner(_context, "NOTE", message);
|
||||
}
|
||||
else if (Helpers.ReadQuestion("Do you want to generate a self-signed SSL certificate?"))
|
||||
{
|
||||
Directory.CreateDirectory($"/bitwarden/ssl/self/{_context.Install.Domain}/");
|
||||
Helpers.WriteLine(_context, "Generating self signed SSL certificate.");
|
||||
_context.Config.Ssl = true;
|
||||
_context.Install.Trusted = false;
|
||||
_context.Install.SelfSignedCert = true;
|
||||
Helpers.Exec("openssl req -x509 -newkey rsa:4096 -sha256 -nodes -days 36500 " +
|
||||
$"-keyout /bitwarden/ssl/self/{_context.Install.Domain}/private.key " +
|
||||
$"-out /bitwarden/ssl/self/{_context.Install.Domain}/certificate.crt " +
|
||||
$"-reqexts SAN -extensions SAN " +
|
||||
$"-config <(cat /usr/lib/ssl/openssl.cnf <(printf '[SAN]\nsubjectAltName=DNS:{_context.Install.Domain}\nbasicConstraints=CA:true')) " +
|
||||
$"-subj \"/C=US/ST=California/L=Santa Barbara/O=Bitwarden Inc./OU=Bitwarden/CN={_context.Install.Domain}\"");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -196,15 +196,35 @@ namespace Bit.Setup
|
||||
|
||||
private static bool ValidateInstallation()
|
||||
{
|
||||
var installationId = Helpers.ReadInput("Enter your installation id (get at https://bitwarden.com/host)");
|
||||
var installationId = string.Empty;
|
||||
var installationKey = string.Empty;
|
||||
|
||||
if (_context.Parameters.ContainsKey("install-id"))
|
||||
{
|
||||
installationId = _context.Parameters["install-id"].ToLowerInvariant();
|
||||
}
|
||||
else
|
||||
{
|
||||
installationId = Helpers.ReadInput("Enter your installation id (get at https://bitwarden.com/host)");
|
||||
}
|
||||
|
||||
if (!Guid.TryParse(installationId.Trim(), out var installationidGuid))
|
||||
{
|
||||
Console.WriteLine("Invalid installation id.");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (_context.Parameters.ContainsKey("install-key"))
|
||||
{
|
||||
installationKey = _context.Parameters["install-key"];
|
||||
}
|
||||
else
|
||||
{
|
||||
installationKey = Helpers.ReadInput("Enter your installation key");
|
||||
}
|
||||
|
||||
_context.Install.InstallationId = installationidGuid;
|
||||
_context.Install.InstallationKey = Helpers.ReadInput("Enter your installation key");
|
||||
_context.Install.InstallationKey = installationKey;
|
||||
|
||||
try
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user