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

Fixes #18788: Use agent certificate in httpd configuration #3699

Merged
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
3 changes: 2 additions & 1 deletion relay/sources/apache/rudder-apache-relay-ssl.conf
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
RewriteEngine On

# List of allowed certificates
SSLCACertificateFile /opt/rudder/etc/ssl/ca.cert
SSLCertificateFile /opt/rudder/etc/ssl/agent.cert
SSLCertificateKeyFile /var/rudder/cfengine-community/ppkeys/localhost.priv

# Explanation
# 1. The Rewriterule pattern is matched
Expand Down
21 changes: 11 additions & 10 deletions relay/sources/rudder-server-relay-postinst
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ APACHE_USER="$3"
APACHE_GROUP="$4"
APACHE_VHOSTDIR="$5"

BACKUP_DIR="/var/backups/rudder/"
LOG_FILE="/var/log/rudder/install/rudder-server-relay-$(date +%Y%m%d%H%M%S).log"

echo "$(date) - Starting rudder-server-relay post installation script" >> ${LOG_FILE}
Expand Down Expand Up @@ -75,19 +76,19 @@ do
htpasswd -bc ${passwdfile} rudder rudder >> ${LOG_FILE} 2>&1
done

# Generate certificates if needed
if [ ! -f /opt/rudder/etc/ssl/rudder.crt ] || [ ! -f /opt/rudder/etc/ssl/rudder.key ]; then
echo -n "INFO: No usable SSL certificate detected for Rudder relay HTTPS support, generating one automatically..."
MACHINE_NAME=$(hostname --fqdn) || MACHINE_NAME=$(hostname)
SHORT_NAME=$(echo "${MACHINE_NAME}" | cut -b -63)
SUBJALTNAME=DNS:${MACHINE_NAME} openssl req -new -batch -x509 -newkey rsa:2048 -subj "/C=FR/ST=France/L=Paris/CN=${SHORT_NAME}/emailAddress=root@${MACHINE_NAME}/" -keyout /opt/rudder/etc/ssl/rudder.key -out /opt/rudder/etc/ssl/rudder.crt -days 1460 -nodes -sha256 -config /opt/rudder/etc/ssl/openssl.cnf -extensions server_cert >/dev/null
chgrp ${APACHE_GROUP} /opt/rudder/etc/ssl/rudder.key && chmod 640 /opt/rudder/etc/ssl/rudder.key
echo " Done"
# Previous HTTPS key and cert
if [ -f /opt/rudder/etc/ssl/rudder.crt ]; then
mv /opt/rudder/etc/ssl/rudder.crt "${BACKUP_DIR}/rudder-`date +%Y%m%d`.crt"
fi
if [ -f /opt/rudder/etc/ssl/rudder.key ]; then
mv /opt/rudder/etc/ssl/rudder.key "${BACKUP_DIR}/rudder-`date +%Y%m%d`.key"
fi

# we now use agent.cert and localhost.priv for HTTPS too

# put this certificate in ca.cert if it doesn't exist (we need at least on certificate there)
# put agent certificate in ca.cert if it doesn't exist (we need at least on certificate there)
if [ ! -f /opt/rudder/etc/ssl/ca.cert ]; then
cp /opt/rudder/etc/ssl/rudder.crt /opt/rudder/etc/ssl/ca.cert
cp /opt/rudder/etc/ssl/agent.cert /opt/rudder/etc/ssl/ca.cert
fi

if [ ! -f /var/rudder/lib/ssl/nodescerts.pem ]; then
Expand Down