This repository has been archived by the owner on Dec 29, 2024. 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.
- Loading branch information
Showing
11 changed files
with
273 additions
and
24 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
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 |
---|---|---|
|
@@ -71,3 +71,4 @@ yarn-error.log | |
|
||
|
||
/.ansible/inventory\.* | ||
/cert |
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,82 @@ | ||
accountsservice | ||
acl | ||
apparmor | ||
apparmor-utils | ||
apt-transport-https | ||
apt-utils | ||
autoconf | ||
binutils | ||
bsdmainutils | ||
build-essential | ||
busybox | ||
ca-certificates | ||
console-setup | ||
cpio | ||
cron | ||
curl | ||
debconf-utils | ||
debian-archive-keyring | ||
debian-keyring | ||
dirmngr | ||
dpkg-dev | ||
ed | ||
file | ||
gettext | ||
gettext-base | ||
git | ||
glib-networking | ||
gnupg2 | ||
gnupg-utils | ||
gpg | ||
gpg-agent | ||
gpgconf | ||
groff | ||
iproute2 | ||
iptables | ||
iso-codes | ||
jq | ||
ldap-utils | ||
less | ||
libdate-manip-perl | ||
libgetopt-complete-perl | ||
libio-socket-ssl-perl | ||
libnet-ldap-perl | ||
locales | ||
logrotate | ||
lsb-release | ||
make | ||
man-db | ||
monit | ||
monitoring-plugins | ||
netcat | ||
netcat-openbsd | ||
openssh-client | ||
openssl | ||
openssl-client | ||
p7zip | ||
p7zip-full | ||
pass | ||
patch | ||
perl | ||
pkg-config | ||
python3-ldap | ||
readline-common | ||
rsync | ||
rsyslog | ||
runit | ||
screen | ||
slapd | ||
socat | ||
software-properties-common | ||
sudo | ||
swig | ||
tree | ||
tzdata | ||
ucf | ||
unzip | ||
virtualenv | ||
virt-what | ||
wget | ||
x11-common | ||
xz-utils | ||
zip |
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,138 @@ | ||
#! /bin/bash | ||
|
||
set -Eeuo pipefail | ||
|
||
declare -i DEBUG=0 | ||
w=$(cd "$(dirname "$0")" && pwd) | ||
|
||
logInfo() { | ||
echo "INFO: $@" | ||
} | ||
|
||
ALLDOMAINS=${ALLDOMAINS:-slapd.local} | ||
PROJ_NAME=DockerMirrorBox | ||
logInfo "Will create certificate with names $ALLDOMAINS" | ||
|
||
CADATE=$(date "+%Y.%m.%d %H:%M") | ||
CAID="$(hostname -f) ${CADATE}" | ||
|
||
CN_CA="${PROJ_NAME} CA Root ${CAID}" | ||
CN_IA="${PROJ_NAME} Intermediate IA ${CAID}" | ||
CN_WEB="${PROJ_NAME} Web Cert ${CAID}" | ||
|
||
CN_CA=${CN_CA:0:64} | ||
CN_IA=${CN_IA:0:64} | ||
CN_WEB=${CN_WEB:0:64} | ||
|
||
for i in $w/cert/certs $w/cert/ca;do | ||
if [ ! -e $i ];then | ||
mkdir -p $i | ||
fi | ||
done | ||
cd $w/cert/ca | ||
|
||
CA_KEY_FILE=${CA_KEY_FILE:-$w/cert/ca/ca.key} | ||
CA_CRT_FILE=${CA_CRT_FILE:-$w/cert/ca/ca.crt} | ||
CA_SRL_FILE=${CA_SRL_FILE:-$w/cert/ca/ca.srl} | ||
|
||
if [ -f "$CA_CRT_FILE" ] ; then | ||
logInfo "CA already exists. Good. We'll reuse it." | ||
if [ ! -f "$CA_SRL_FILE" ] ; then | ||
echo 01 > ${CA_SRL_FILE} | ||
fi | ||
else | ||
logInfo "No CA was found. Generating one." | ||
logInfo "*** Please *** make sure to mount /ca as a volume -- if not, everytime this container starts, it will regenerate the CA and nothing will work." | ||
|
||
openssl genrsa -des3 -passout pass:foobar -out ${CA_KEY_FILE} 4096 | ||
|
||
logInfo "generate CA cert with key and self sign it: ${CAID}" | ||
openssl req -new -x509 -days 1300 -sha256 -key ${CA_KEY_FILE} -out ${CA_CRT_FILE} -passin pass:foobar -subj "/C=NL/ST=Noord Holland/L=Amsterdam/O=ME/OU=IT/CN=${CN_CA}" -extensions IA -config <( | ||
cat <<-EOF | ||
[req] | ||
distinguished_name = dn | ||
[dn] | ||
[IA] | ||
basicConstraints = critical,CA:TRUE | ||
keyUsage = critical, digitalSignature, cRLSign, keyCertSign | ||
subjectKeyIdentifier = hash | ||
EOF | ||
) | ||
|
||
[[ ${DEBUG} -gt 0 ]] && logInfo "show the CA cert details" | ||
[[ ${DEBUG} -gt 0 ]] && openssl x509 -noout -text -in ${CA_CRT_FILE} | ||
|
||
echo 01 > ${CA_SRL_FILE} | ||
|
||
fi | ||
|
||
cd $w/cert/certs | ||
|
||
logInfo "Generate IA key" | ||
openssl genrsa -des3 -passout pass:foobar -out ia.key 4096 &> /dev/null | ||
|
||
logInfo "Create a signing request for the IA: ${CAID}" | ||
openssl req -new -key ia.key -out ia.csr -passin pass:foobar -subj "/C=NL/ST=Noord Holland/L=Amsterdam/O=ME/OU=IT/CN=${CN_IA}" -reqexts IA -config <( | ||
cat <<-EOF | ||
[req] | ||
distinguished_name = dn | ||
[dn] | ||
[IA] | ||
basicConstraints = critical,CA:TRUE,pathlen:0 | ||
keyUsage = critical, digitalSignature, cRLSign, keyCertSign | ||
subjectKeyIdentifier = hash | ||
EOF | ||
) | ||
|
||
[[ ${DEBUG} -gt 0 ]] && logInfo "Show the singing request, to make sure extensions are there" | ||
[[ ${DEBUG} -gt 0 ]] && openssl req -in ia.csr -noout -text | ||
|
||
logInfo "Sign the IA request with the CA cert and key, producing the IA cert" | ||
openssl x509 -req -days 730 -in ia.csr -CA ${CA_CRT_FILE} -CAkey ${CA_KEY_FILE} -CAserial ${CA_SRL_FILE} -out ia.crt -passin pass:foobar -extensions IA -extfile <( | ||
cat <<-EOF | ||
[req] | ||
distinguished_name = dn | ||
[dn] | ||
[IA] | ||
basicConstraints = critical,CA:TRUE,pathlen:0 | ||
keyUsage = critical, digitalSignature, cRLSign, keyCertSign | ||
subjectKeyIdentifier = hash | ||
EOF | ||
) &> /dev/null | ||
|
||
|
||
[[ ${DEBUG} -gt 0 ]] && logInfo "show the IA cert details" | ||
[[ ${DEBUG} -gt 0 ]] && openssl x509 -noout -text -in ia.crt | ||
|
||
logInfo "Initialize the serial number for signed certificates" | ||
echo 01 > ia.srl | ||
|
||
logInfo "Create the key (w/o passphrase..)" | ||
openssl genrsa -des3 -passout pass:foobar -out web.orig.key 2048 &> /dev/null | ||
openssl rsa -passin pass:foobar -in web.orig.key -out web.key &> /dev/null | ||
|
||
SANREQ=DNS:$(python -c "print(',DNS:'.join('$ALLDOMAINS'.split(',')))") | ||
|
||
logInfo "Create the signing request, using extensions" | ||
openssl req -new -key web.key -sha256 -out web.csr -passin pass:foobar -subj "/C=NL/ST=Noord Holland/L=Amsterdam/O=ME/OU=IT/CN=${CN_WEB}" -reqexts SAN -config <(cat <(printf "[req]\ndistinguished_name = dn\n[dn]\n[SAN]\nsubjectAltName=${SANREQ}")) | ||
|
||
[[ ${DEBUG} -gt 0 ]] && logInfo "Show the singing request, to make sure extensions are there" | ||
[[ ${DEBUG} -gt 0 ]] && openssl req -in web.csr -noout -text | ||
|
||
logInfo "Sign the request, using the intermediate cert and key" | ||
openssl x509 -req -days 365 -in web.csr -CA ia.crt -CAkey ia.key -out web.crt -passin pass:foobar -extensions SAN -extfile <(cat <(printf "[req]\ndistinguished_name = dn\n[dn]\n[SAN]\nsubjectAltName=${SANREQ}")) &> /dev/null | ||
|
||
[[ ${DEBUG} -gt 0 ]] && logInfo "Show the final cert details" | ||
[[ ${DEBUG} -gt 0 ]] && openssl x509 -noout -text -in web.crt | ||
|
||
logInfo "Concatenating fullchain.pem..." | ||
cat web.crt ia.crt ${CA_CRT_FILE} > fullchain.pem | ||
|
||
logInfo "Concatenating fullchain_with_key.pem" | ||
cat fullchain.pem web.key > fullchain_with_key.pem | ||
|
||
cd $w | ||
cp $w/cert/certs/fullchain.pem $w/cert/chain.pem | ||
cp $w/cert/certs/web.key $w/cert/privkey.pem | ||
cp $w/cert/certs/web.crt $w/cert/cert.pem | ||
chmod 755 $w/cert/*.pem |
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,4 +1,7 @@ | ||
version: '3.7' | ||
services: | ||
slapd: | ||
build: {context: "."} | ||
build: | ||
context: "." | ||
args: | ||
BASE: "${BASE-corpusops/ubuntu-bare:20.04}" |
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