This repository has been archived by the owner on Jun 26, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #289 from neicnordic/fix/dev-utils-certs
Fix/dev utils certs
- Loading branch information
Showing
20 changed files
with
374 additions
and
184 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
name: linting check | ||
on: [push, pull_request] | ||
on: [push] | ||
jobs: | ||
|
||
lint: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
name: Go tests | ||
on: [push, pull_request] | ||
on: [push] | ||
jobs: | ||
|
||
test: | ||
|
@@ -17,27 +17,8 @@ jobs: | |
- name: Check out source code | ||
uses: actions/checkout@v3 | ||
|
||
- name: generate certificates | ||
run: cd dev_utils && /bin/sh make_certs.sh | ||
|
||
- name: Deploy containers | ||
run: cd dev_utils && docker-compose up -d s3_backend mq_server | ||
|
||
- name: Wait for containers to start | ||
run: | | ||
RETRY_TIMES=0 | ||
for p in mq s3 | ||
do | ||
until docker ps -f name=$p --format {{.Status}} | grep "(healthy)" | ||
do echo "waiting for $p to become ready" | ||
RETRY_TIMES=$((RETRY_TIMES+1)); | ||
if [ $RETRY_TIMES -eq 30 ]; then exit 1; fi | ||
sleep 10; | ||
done | ||
done | ||
- name: Calc coverage | ||
run: go test -tags live -coverprofile=coverage.txt -covermode=atomic | ||
- name: Run test container | ||
run: cd dev_utils && GOLANG_VERSION=${{ matrix.go-version }} docker compose run tests | ||
|
||
- name: Codecov | ||
uses: codecov/[email protected] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,4 +12,7 @@ | |
*.out | ||
|
||
# log dumps | ||
*.dump | ||
*.dump | ||
|
||
# coverage report | ||
coverage.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
#!/bin/sh | ||
|
||
set -e | ||
|
||
out_dir="/cert_gen" | ||
|
||
# install openssl if it's missing | ||
if [ ! "$(command -v openssl)" ]; | ||
then | ||
apk add openssl | ||
fi | ||
|
||
script_dir="$(dirname "$0")" | ||
mkdir -p "$out_dir" | ||
|
||
# list all certificates we want, so that we can check if they already exist | ||
s3_certs="/s3_certs/CAs/public.crt /s3_certs/public.crt /s3_certs/private.key" | ||
mq_certs="/mq_certs/ca.crt /mq_certs/mq.crt /mq_certs/mq.key" | ||
pub_cert="/pubcert/public.crt" | ||
proxy_certs="/proxy_certs/ca.crt /proxy_certs/client.crt /proxy_certs/client.key /proxy_certs/proxy.crt /proxy_certs/proxy.key" | ||
targets="$s3_certs $mq_certs $pub_cert $proxy_certs" | ||
|
||
echo "" | ||
echo "Checking certificates" | ||
recreate="false" | ||
# check if certificates exist | ||
for target in $targets | ||
do | ||
if [ ! -f "$target" ] | ||
then | ||
recreate="true" | ||
break | ||
fi | ||
done | ||
|
||
# only recreate certificates if any certificate is missing | ||
if [ "$recreate" = "false" ] | ||
then | ||
echo "certificates already exists" | ||
exit 0 | ||
fi | ||
|
||
# create CA certificate | ||
openssl req -config "$script_dir/ssl.cnf" -new -sha256 -nodes -extensions v3_ca -out "$out_dir/ca.csr" -keyout "$out_dir/ca-key.pem" | ||
openssl req -config "$script_dir/ssl.cnf" -key "$out_dir/ca-key.pem" -x509 -new -days 7300 -sha256 -nodes -extensions v3_ca -out "$out_dir/ca.crt" | ||
|
||
# Create certificate for MQ | ||
openssl req -config "$script_dir/ssl.cnf" -new -nodes -newkey rsa:4096 -keyout "$out_dir/mq.key" -out "$out_dir/mq.csr" -extensions server_cert | ||
openssl x509 -req -in "$out_dir/mq.csr" -days 1200 -CA "$out_dir/ca.crt" -CAkey "$out_dir/ca-key.pem" -set_serial 01 -out "$out_dir/mq.crt" -extensions server_cert -extfile "$script_dir/ssl.cnf" | ||
|
||
# Create certificate for Proxy | ||
openssl req -config "$script_dir/ssl.cnf" -new -nodes -newkey rsa:4096 -keyout "$out_dir/proxy.key" -out "$out_dir/proxy.csr" -extensions server_cert | ||
openssl x509 -req -in "$out_dir/proxy.csr" -days 1200 -CA "$out_dir/ca.crt" -CAkey "$out_dir/ca-key.pem" -set_serial 01 -out "$out_dir/proxy.crt" -extensions server_cert -extfile "$script_dir/ssl.cnf" | ||
|
||
# Create certificate for minio | ||
openssl req -config "$script_dir/ssl.cnf" -new -nodes -newkey rsa:4096 -keyout "$out_dir/s3.key" -out "$out_dir/s3.csr" -extensions server_cert | ||
openssl x509 -req -in "$out_dir/s3.csr" -days 1200 -CA "$out_dir/ca.crt" -CAkey "$out_dir/ca-key.pem" -set_serial 01 -out "$out_dir/s3.crt" -extensions server_cert -extfile "$script_dir/ssl.cnf" | ||
|
||
# Create client certificate | ||
openssl req -config "$script_dir/ssl.cnf" -new -nodes -newkey rsa:4096 -keyout "$out_dir/client.key" -out "$out_dir/client.csr" -extensions client_cert -subj "/CN=admin" | ||
openssl x509 -req -in "$out_dir/client.csr" -days 1200 -CA "$out_dir/ca.crt" -CAkey "$out_dir/ca-key.pem" -set_serial 01 -out "$out_dir/client.crt" -extensions client_cert -extfile "$script_dir/ssl.cnf" | ||
|
||
# fix permissions | ||
chmod 644 "$out_dir"/* | ||
chown -R root:root "$out_dir"/* | ||
chmod 600 "$out_dir"/*-key.pem | ||
|
||
# move certificates to volumes | ||
mkdir -p /s3_certs/CAs | ||
cp -p "$out_dir/ca.crt" /s3_certs/CAs/public.crt | ||
cp -p "$out_dir/s3.crt" /s3_certs/public.crt | ||
cp -p "$out_dir/s3.key" /s3_certs/private.key | ||
|
||
cp -p "$out_dir/ca.crt" /mq_certs/ca.crt | ||
cp -p "$out_dir/mq.crt" /mq_certs/mq.crt | ||
cp -p "$out_dir/mq.key" /mq_certs/mq.key | ||
|
||
cp -p "$out_dir/ca.crt" /pubcert/public.crt | ||
|
||
cp -p "$out_dir/ca.crt" /proxy_certs/ca.crt | ||
cp -p "$out_dir/client.crt" /proxy_certs/client.crt | ||
cp -p "$out_dir/client.key" /proxy_certs/client.key | ||
cp -p "$out_dir/proxy.crt" /proxy_certs/proxy.crt | ||
cp -p "$out_dir/proxy.key" /proxy_certs/proxy.key |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.