From 7cf54b0e4c2eefa5999228a82e4132d4ae8ca471 Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Tue, 8 Aug 2017 14:35:31 -0400 Subject: [PATCH] setup for ssl certs --- docker/docker-compose.linux.yml | 2 +- docker/docker-compose.override.yml | 2 +- docker/docker-compose.windows.yml | 2 +- scripts/setup.ps1 | 19 +++---- scripts/setup.sh | 9 ++-- util/Setup/Program.cs | 87 ++++++++++++++++++++++++------ 6 files changed, 89 insertions(+), 32 deletions(-) diff --git a/docker/docker-compose.linux.yml b/docker/docker-compose.linux.yml index e3b94a763..d9ab2fe5d 100644 --- a/docker/docker-compose.linux.yml +++ b/docker/docker-compose.linux.yml @@ -18,4 +18,4 @@ services: volumes: - /etc/bitwarden/nginx:/etc/bitwarden/nginx - /etc/bitwarden/letsencrypt:/etc/letsencrypt - - /etc/bitwarden/ssl:/etc/certificates + - /etc/bitwarden/ssl:/etc/ssl diff --git a/docker/docker-compose.override.yml b/docker/docker-compose.override.yml index 20ffe537d..8baa6cdc1 100644 --- a/docker/docker-compose.override.yml +++ b/docker/docker-compose.override.yml @@ -18,6 +18,6 @@ services: volumes: - c:/bitwarden/nginx:/etc/bitwarden/nginx - c:/bitwarden/letsencrypt:/etc/letsencrypt - - c:/bitwarden/ssl:/etc/certificates + - c:/bitwarden/ssl:/etc/ssl volumes: mssql_data: diff --git a/docker/docker-compose.windows.yml b/docker/docker-compose.windows.yml index 20ffe537d..8baa6cdc1 100644 --- a/docker/docker-compose.windows.yml +++ b/docker/docker-compose.windows.yml @@ -18,6 +18,6 @@ services: volumes: - c:/bitwarden/nginx:/etc/bitwarden/nginx - c:/bitwarden/letsencrypt:/etc/letsencrypt - - c:/bitwarden/ssl:/etc/certificates + - c:/bitwarden/ssl:/etc/ssl volumes: mssql_data: diff --git a/scripts/setup.ps1 b/scripts/setup.ps1 index a637f934e..3eefc3ed6 100644 --- a/scripts/setup.ps1 +++ b/scripts/setup.ps1 @@ -1,18 +1,19 @@ param ( - [string]$outputDir = "c:/bitwarden", - [string]$domain = $( Read-Host "Please enter your domain name (i.e. bitwarden.company.com)" ), - [string]$email = $( Read-Host "Please enter your email address: " ), - [string]$letsencrypt = $( Read-Host "Generate Let's Encrypt Cert (y/n)" ) + [string]$outputDir = "c:/bitwarden", + [string]$domain = $( Read-Host "Enter your domain name (i.e. bitwarden.company.com)" ), + [string]$email = $( Read-Host "Enter your email address" ), + [string]$letsencrypt = $( Read-Host "Do you want to use Let's Encrypt to generate a free SSL certificate? (y/n)" ) ) +docker --version + $dockerDir="../docker" $databasePassword=-join ((48..57) + (97..122) | Get-Random -Count 32 | % {[char]$_}) -docker --version - -#mkdir -p $outputDir/letsencrypt/live/$domain -#docker run -it --rm -p 80:80 -v $outputDir/letsencrypt:/etc/letsencrypt/ certbot/certbot certonly --standalone --noninteractive --preferred-challenges http --email $email --agree-tos -d $domain -#docker run -it --rm -v $outputDir/letsencrypt/live:/certificates/ bitwarden/openssl openssl dhparam -out /certificates/$domain/dhparam.pem 2048 +if($letsencrypt -eq "y") { + mkdir -p $outputDir/letsencrypt/live/$domain + docker run -it --rm -p 80:80 -v $outputDir/letsencrypt:/etc/letsencrypt/ certbot/certbot certonly --standalone --noninteractive --preferred-challenges http --email $email --agree-tos -d $domain +} docker run -it --rm -v ${outputDir}:/bitwarden bitwarden/setup dotnet Setup.dll -domain ${domain} -letsencrypt ${letsencrypt} -db_pass ${databasePassword} diff --git a/scripts/setup.sh b/scripts/setup.sh index 467b661cb..89aab2193 100644 --- a/scripts/setup.sh +++ b/scripts/setup.sh @@ -3,18 +3,19 @@ set -e echo "Please enter your domain name (i.e. bitwarden.company.com): " read DOMAIN -echo -e "\nPlease enter your email address (used to generate an HTTPS certificate with LetsEncrypt): " +echo -e "\nPlease enter your email address: " read EMAIL +echo -e "\nDo you want to use Let's Encrypt to generate a free SSL certificate (y/n)? " +read LETS_ENCRYPT -OUTPUT_DIR=./bitwarden +OUTPUT_DIR=/etc/bitwarden DATABASE_PASSWORD=$(LC_ALL=C tr -dc A-Za-z0-9