Skip to content
This repository was archived by the owner on Dec 30, 2025. It is now read-only.

Commit 5ee4c41

Browse files
committed
fix(ssl-manager.sh): adjust permissions and ownership for TLS files
Ensure the server key is readable by the container user by changing its permissions to 644. Set the TLS directory permissions to 755 to make it accessible. Attempt to set ownership of the certificate and key files to user 1001, but do not fail if this operation is not permitted. These changes improve compatibility with containerized environments where specific user permissions are required.
1 parent 03b8618 commit 5ee4c41

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

scripts/ssl-manager.sh

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -145,9 +145,12 @@ generate_self_signed_certificate() {
145145
# Generate self-signed certificate
146146
openssl req -x509 -newkey rsa:4096 -keyout "$TLS_DIR/server.key.pem" -out "$TLS_DIR/server.cert.pem" -days 365 -nodes -subj "/CN=$DOMAIN" 2>/dev/null
147147

148-
# Set proper permissions
148+
# Set proper permissions and ownership
149149
chmod 644 "$TLS_DIR/server.cert.pem"
150-
chmod 600 "$TLS_DIR/server.key.pem"
150+
chmod 644 "$TLS_DIR/server.key.pem" # Make readable by container user
151+
chmod 755 "$TLS_DIR" # Make directory accessible
152+
# Try to set ownership, but don't fail if we can't
153+
chown 1001:1001 "$TLS_DIR/server.cert.pem" "$TLS_DIR/server.key.pem" 2>/dev/null || true
151154

152155
log_success "Self-signed certificate generated successfully!"
153156
log_warn "This is a self-signed certificate - browsers will show security warnings"
@@ -173,9 +176,12 @@ copy_certificates() {
173176
docker compose run --rm certbot cat "/etc/letsencrypt/live/$DOMAIN/fullchain.pem" > "$TLS_DIR/server.cert.pem"
174177
docker compose run --rm certbot cat "/etc/letsencrypt/live/$DOMAIN/privkey.pem" > "$TLS_DIR/server.key.pem"
175178

176-
# Set proper permissions
179+
# Set proper permissions and ownership
177180
chmod 644 "$TLS_DIR/server.cert.pem"
178-
chmod 600 "$TLS_DIR/server.key.pem"
181+
chmod 644 "$TLS_DIR/server.key.pem" # Make readable by container user
182+
chmod 755 "$TLS_DIR" # Make directory accessible
183+
# Try to set ownership, but don't fail if we can't
184+
chown 1001:1001 "$TLS_DIR/server.cert.pem" "$TLS_DIR/server.key.pem" 2>/dev/null || true
179185

180186
log_success "Certificates copied from certbot container to $TLS_DIR"
181187
else
@@ -185,9 +191,12 @@ copy_certificates() {
185191
cp "$letsencrypt_dir/fullchain.pem" "$TLS_DIR/server.cert.pem"
186192
cp "$letsencrypt_dir/privkey.pem" "$TLS_DIR/server.key.pem"
187193

188-
# Set proper permissions
194+
# Set proper permissions and ownership
189195
chmod 644 "$TLS_DIR/server.cert.pem"
190-
chmod 600 "$TLS_DIR/server.key.pem"
196+
chmod 644 "$TLS_DIR/server.key.pem" # Make readable by container user
197+
chmod 755 "$TLS_DIR" # Make directory accessible
198+
# Try to set ownership, but don't fail if we can't
199+
chown 1001:1001 "$TLS_DIR/server.cert.pem" "$TLS_DIR/server.key.pem" 2>/dev/null || true
191200

192201
log_success "Certificates copied from Let's Encrypt directory to $TLS_DIR"
193202
else

0 commit comments

Comments
 (0)