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

T5683: Fix reverse-proxy PKI filenames mismatch (backport #2405) #2407

Merged
merged 1 commit into from
Oct 26, 2023
Merged
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
14 changes: 6 additions & 8 deletions src/conf_mode/load-balancing-haproxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@ def generate(lb):
if os.path.isfile(file):
os.unlink(file)
# Delete old directories
#if os.path.isdir(load_balancing_dir):
# rmtree(load_balancing_dir, ignore_errors=True)
if os.path.isdir(load_balancing_dir):
rmtree(load_balancing_dir, ignore_errors=True)

return None

Expand All @@ -106,15 +106,12 @@ def generate(lb):
# SSL Certificates for frontend
for front, front_config in lb['service'].items():
if 'ssl' in front_config:
cert_file_path = os.path.join(load_balancing_dir, 'cert.pem')
cert_key_path = os.path.join(load_balancing_dir, 'cert.pem.key')
ca_cert_file_path = os.path.join(load_balancing_dir, 'ca.pem')

if 'certificate' in front_config['ssl']:
#cert_file_path = os.path.join(load_balancing_dir, 'cert.pem')
#cert_key_path = os.path.join(load_balancing_dir, 'cert.key')
cert_name = front_config['ssl']['certificate']
pki_cert = lb['pki']['certificate'][cert_name]
cert_file_path = os.path.join(load_balancing_dir, f'{cert_name}.pem')
cert_key_path = os.path.join(load_balancing_dir, f'{cert_name}.pem.key')

with open(cert_file_path, 'w') as f:
f.write(wrap_certificate(pki_cert['certificate']))
Expand All @@ -126,18 +123,19 @@ def generate(lb):
if 'ca_certificate' in front_config['ssl']:
ca_name = front_config['ssl']['ca_certificate']
pki_ca_cert = lb['pki']['ca'][ca_name]
ca_cert_file_path = os.path.join(load_balancing_dir, f'{ca_name}.pem')

with open(ca_cert_file_path, 'w') as f:
f.write(wrap_certificate(pki_ca_cert['certificate']))

# SSL Certificates for backend
for back, back_config in lb['backend'].items():
if 'ssl' in back_config:
ca_cert_file_path = os.path.join(load_balancing_dir, 'ca.pem')

if 'ca_certificate' in back_config['ssl']:
ca_name = back_config['ssl']['ca_certificate']
pki_ca_cert = lb['pki']['ca'][ca_name]
ca_cert_file_path = os.path.join(load_balancing_dir, f'{ca_name}.pem')

with open(ca_cert_file_path, 'w') as f:
f.write(wrap_certificate(pki_ca_cert['certificate']))
Expand Down