From b3a4ec2085965287388c96186b41136918709f88 Mon Sep 17 00:00:00 2001 From: Semen Bezrukov Date: Wed, 29 Apr 2020 13:05:46 +0300 Subject: [PATCH] Fix script & test --- .travis.yml | 18 +++++++++++------- tests/test.sh | 45 ++++++++++++++++++++++----------------------- 2 files changed, 33 insertions(+), 30 deletions(-) diff --git a/.travis.yml b/.travis.yml index 478a3d7..8467317 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,8 +14,18 @@ env: POSTGRES_DB: mydb POSTGRES_USER: myuser - # certificates + # no certificates - config: certs.yml + ssl: false + + # certificates (default tls if onlyoffice not exists) + - config: certs.yml + + # old certificates path (default onlyoffice if exists) + - config: certs.yml + private_key: onlyoffice.key + certificate_request: onlyoffice.csr + certificate: onlyoffice.crt # custom certificates path - config: certs.yml @@ -25,12 +35,6 @@ env: SSL_CERTIFICATE_PATH: /var/www/onlyoffice/Data/certs/mycert.crt SSL_KEY_PATH: /var/www/onlyoffice/Data/certs/mycert.key - # old certificates path - - config: certs.yml - private_key: onlyoffice.key - certificate_request: onlyoffice.csr - certificate: onlyoffice.crt - # deprecated variables - config: postgres-old.yml diff --git a/tests/test.sh b/tests/test.sh index 31e4f18..01d8ea2 100755 --- a/tests/test.sh +++ b/tests/test.sh @@ -1,32 +1,31 @@ #!/bin/bash -url=${url:-"https://localhost"} -private_key=tls.key -certificate_request=tls.csr -certificate=tls.crt +ssl=${ssl:-true} +private_key=${private_key:-tls.key} +certificate_request=${certificate_request:-tls.csr} +certificate=${certificate:-tls.crt} # Generate certificate -openssl genrsa -out ${private_key} 2048 -openssl req \ - -new \ - -subj "/C=US/ST=Denial/L=Springfield/O=Dis/CN=backendserver-address" \ - -key ${private_key} \ - -out ${certificate_request} -openssl x509 \ - -req \ - -days 365 \ - -in ${certificate_request} \ - -signkey ${private_key} \ - -out ${certificate} +if [[ $ssl == "true" ]]; then + url=${url:-"https://localhost"} -# Strengthening the server security -openssl dhparam -out dhparam.pem 2048 + mkdir -p data/certs + pushd data/certs -mkdir -p data/certs -cp $private_key data/certs/ -cp $certificate data/certs/ -cp dhparam.pem data/certs/ -chmod 400 data/certs/$private_key + openssl genrsa -out ${private_key} 2048 + openssl req \ + -new \ + -subj "/C=US/ST=Denial/L=Springfield/O=Dis/CN=www.example.com" \ + -key ${private_key} \ + -out ${certificate_request} + openssl x509 -req -days 365 -in ${certificate_request} -signkey ${private_key} -out ${certificate} + openssl dhparam -out dhparam.pem 2048 + chmod 400 ${private_key} + + popd +else + url=${url:-"http://localhost"} +fi # Check if the yml exists if [[ ! -f $config ]]; then