Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[9.0] use containerized certs creation #8005

Draft
wants to merge 2 commits into
base: integration
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -93,13 +93,9 @@ the private key. You will need two different sets certificates and the CA certif
The following commands should do the trick for you, by creating a fake CA, a fake user certificate, and a fake host certificate::

cd $DEVROOT/DIRAC
git checkout release/integration
source tests/Jenkins/utilities.sh
generateCA
generateCertificates 365
generateUserCredentials 365
docker run ghcr.io/diracgrid/diracx/certificates-generation:latest
mkdir -p ~/.globus/
cp $DEVROOT/user/*.{pem,key} ~/.globus/
docker cp certificates-generation:/ca/certs/client.{pem,key} ~/.globus/
mv ~/.globus/client.key ~/.globus/userkey.pem
mv ~/.globus/client.pem ~/.globus/usercert.pem

Expand Down
4 changes: 1 addition & 3 deletions src/DIRAC/Core/DISET/private/Service.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,7 @@ def initialize(self):
"validNames": self._validNames,
"csPaths": [PathFinder.getServiceSection(svcName) for svcName in self._validNames],
}
self.securityLogging = Operations().getValue("EnableSecurityLogging", False) and getServiceOption(
self._serviceInfoDict, "EnableSecurityLogging", False
)
self.securityLogging = Operations().getValue("EnableSecurityLogging", False)

# Initialize Monitoring
# The import needs to be here because of the CS must be initialized before importing
Expand Down
21 changes: 19 additions & 2 deletions tests/CI/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
volumes:
# Volume used to store the certificates of dirac
certs_data:
# Volume used to store the config of diracx
diracx-cs-store:
# Volume used to store the pair of keys to sign the tokens
Expand Down Expand Up @@ -101,6 +103,15 @@ services:
command: /home/dirac/LocalRepo/ALTERNATIVE_MODULES/DIRAC/tests/CI/check_db_initialized.sh
pull_policy: always

dirac-init-certificates:
image: ghcr.io/diracgrid/diracx/certificates-generation:latest
container_name: dirac-init-certificates
volumes:
- certs_data:/ca/certs/
entrypoint: |
/entrypoint.sh
pull_policy: always

dirac-server:
image: ${CI_REGISTRY_IMAGE}/${HOST_OS}-dirac
container_name: server
Expand All @@ -116,20 +127,23 @@ services:
condition: service_started
iam-login-service:
condition: service_healthy
dirac-init-certificates:
condition: service_completed_successfully # Let the init container create the certificates
diracx-init-key:
condition: service_completed_successfully # Let the init container create the signing key
diracx-init-cs:
condition: service_completed_successfully # Let the init container create the cs
ulimits:
nofile: 8192
volumes:
- certs_data:/ca/certs
- diracx-cs-store:/cs_store
- diracx-key-store:/signing-key
environment:
- DIRACX_CONFIG_BACKEND_URL=git+file:///cs_store/initialRepo
- DIRACX_SERVICE_AUTH_TOKEN_KEY=file:///signing-key/rs256.key
pull_policy: always
command: ["sleep", "infinity"] # This is necessary because of the issue described in https://github.com/moby/moby/issues/42275. What is added here is a hack/workaround.
pull_policy: always


dirac-client:
Expand All @@ -141,8 +155,10 @@ services:
- dirac-server
ulimits:
nofile: 8192
pull_policy: always
volumes:
- certs_data:/ca/certs
command: ["sleep", "infinity"] # This is necessary because of the issue described in https://github.com/moby/moby/issues/42275. What is added here is a hack/workaround.
pull_policy: always

dirac-pilot:
image: ${CI_REGISTRY_IMAGE}/${HOST_OS}-dirac
Expand All @@ -152,6 +168,7 @@ services:
depends_on:
- dirac-server
volumes:
- certs_data:/ca/certs
- type: bind
source: ${CVMFS_DIR}
target: /cvmfs
Expand Down
110 changes: 0 additions & 110 deletions tests/Jenkins/config/ci/openssl_config_ca.cnf

This file was deleted.

37 changes: 0 additions & 37 deletions tests/Jenkins/config/ci/openssl_config_host.cnf

This file was deleted.

20 changes: 0 additions & 20 deletions tests/Jenkins/config/ci/openssl_config_user.cnf

This file was deleted.

38 changes: 25 additions & 13 deletions tests/Jenkins/dirac_ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,7 @@ source "${TESTCODE}/DIRAC/tests/Jenkins/utilities.sh"
installSite() {
echo "==> [installSite]"

generateCA
generateCertificates

echo -n > "${SERVERINSTALLDIR}/dirac-ci-install.cfg"
# echo -n > "${SERVERINSTALLDIR}/dirac-ci-install.cfg"
getCFGFile

echo "==> Fixing install.cfg file"
Expand Down Expand Up @@ -127,7 +124,30 @@ installSite() {
bash "installer.sh"
rm "installer.sh"
echo "source \"$PWD/diracos/diracosrc\"" > "$PWD/bashrc"
mv "${SERVERINSTALLDIR}/etc/grid-security/"* "${SERVERINSTALLDIR}/diracos/etc/grid-security/"

mkdir -p "${SERVERINSTALLDIR}/diracos/etc/grid-security/certificates/"
mkdir -p "${SERVERINSTALLDIR}/user/"

echo "==> CAs and certificates"

# Copy the CA to the list of trusted CA
cp "/ca/certs/ca.cert.pem" "${SERVERINSTALLDIR}/diracos/etc/grid-security/certificates/"

# Copy the cert and host key to the certificates directory
cp /ca/certs/hostcert.pem "${SERVERINSTALLDIR}/diracos/etc/grid-security/"
cp /ca/certs/hostkey.pem "${SERVERINSTALLDIR}/diracos/etc/grid-security/"

# Generate the hash link file required by openSSL to index CA certificates
caHash=$(openssl x509 -in "${SERVERINSTALLDIR}/diracos/etc/grid-security/certificates/ca.cert.pem" -noout -hash)
# We make a relative symlink on purpose (i.e. not the full path to ca.cert.pem)
# because otherwise the BundleDeliveryClient will send the full path, which
# will be wrong on the client
ln -s "${SERVERINSTALLDIR}/diracos/etc/grid-security/certificates/ca.cert.pem" "${SERVERINSTALLDIR}/diracos/etc/grid-security/certificates/$caHash.0"

# Copy the user cert and key to the correct directory
cp /ca/certs/client.pem "${SERVERINSTALLDIR}/user/"
cp /ca/certs/client.key "${SERVERINSTALLDIR}/user/"

rm -rf "${SERVERINSTALLDIR}/etc"
ln -s "${SERVERINSTALLDIR}/diracos/etc" "${SERVERINSTALLDIR}/etc"
source diracos/diracosrc
Expand All @@ -136,7 +156,6 @@ installSite() {
done
cd -


echo "==> Sourcing bashrc"
source "${SERVERINSTALLDIR}/bashrc"

Expand Down Expand Up @@ -212,13 +231,6 @@ fullInstallDIRAC() {
cat "${SERVERINSTALLDIR}/diracos/etc/Production.cfg"
fi

# Dealing with security stuff
# generateCertificates
if ! generateUserCredentials; then
echo "ERROR: generateUserCredentials failed" >&2
exit 1
fi

if ! diracCredentials; then
echo "ERROR: diracCredentials failed" >&2
exit 1
Expand Down
Loading
Loading