SSL cert: Use actual hostname instead of 'localhost' default

When STEGASOO_HOSTNAME env var is not set, use socket.gethostname()
to get the actual machine hostname for certificate generation.

This ensures the cert includes proper hostname.local SAN.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Aaron D. Lee
2026-01-06 22:16:23 -05:00
parent 70da348bce
commit a98df5f9a0

View File

@@ -31,6 +31,7 @@ import time
from concurrent.futures import ThreadPoolExecutor from concurrent.futures import ThreadPoolExecutor
from pathlib import Path from pathlib import Path
import temp_storage
from auth import ( from auth import (
MAX_CHANNEL_KEYS, MAX_CHANNEL_KEYS,
MAX_USERS, MAX_USERS,
@@ -83,7 +84,6 @@ from flask import (
) )
from PIL import Image from PIL import Image
from ssl_utils import ensure_certs from ssl_utils import ensure_certs
import temp_storage
os.environ["NUMPY_MADVISE_HUGEPAGE"] = "0" os.environ["NUMPY_MADVISE_HUGEPAGE"] = "0"
os.environ["OMP_NUM_THREADS"] = "1" os.environ["OMP_NUM_THREADS"] = "1"
@@ -2532,7 +2532,8 @@ if __name__ == "__main__":
# HTTPS configuration # HTTPS configuration
ssl_context = None ssl_context = None
if app.config.get("HTTPS_ENABLED", False): if app.config.get("HTTPS_ENABLED", False):
hostname = os.environ.get("STEGASOO_HOSTNAME", "localhost") import socket
hostname = os.environ.get("STEGASOO_HOSTNAME") or socket.gethostname()
try: try:
cert_path, key_path = ensure_certs(base_dir, hostname) cert_path, key_path = ensure_certs(base_dir, hostname)
if cert_path.exists() and key_path.exists(): if cert_path.exists() and key_path.exists():