Skip to content

Commit

Permalink
Expose ssl_protocols from nginx configuration in harbor.yml
Browse files Browse the repository at this point in the history
Signed-off-by: malmor <[email protected]>
  • Loading branch information
malmor committed Jun 20, 2024
1 parent 02b3561 commit 2ee5dc6
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 2 deletions.
4 changes: 3 additions & 1 deletion make/harbor.yml.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ https:
# The path of cert and key files for nginx
certificate: /your/certificate/path
private_key: /your/private/key/path
# configure ssl protocols (default: TLSv1.2 TLSv1.3)
# ssl_protocols: TLSv1.2 TLSv1.3
# enable strong ssl ciphers (default: false)
# strong_ssl_ciphers: false

Expand Down Expand Up @@ -206,7 +208,7 @@ _version: 2.11.0
# # host for redis+sentinel:
# # <host_sentinel1>:<port_sentinel1>,<host_sentinel2>:<port_sentinel2>,<host_sentinel3>:<port_sentinel3>
# host: redis:6379
# password:
# password:
# # Redis AUTH command was extended in Redis 6, it is possible to use it in the two-arguments AUTH <username> <password> form.
# # there's a known issue when using external redis username ref:https://github.com/goharbor/harbor/issues/18892
# # if you care about the image pull/push performance, please refer to this https://github.com/goharbor/harbor/wiki/Harbor-FAQs#external-redis-username-password-usage
Expand Down
4 changes: 4 additions & 0 deletions make/photon/prepare/templates/nginx/nginx.https.conf.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,11 @@ http {
ssl_certificate_key {{ssl_cert_key}};

# Recommendations from https://raymii.org/s/tutorials/Strong_SSL_Security_On_nginx.html
{% if ssl_protocols is defined %}
ssl_protocols {{ssl_protocols}};
{% else %}
ssl_protocols TLSv1.2 TLSv1.3;
{% endif %}
{% if strong_ssl_ciphers %}
ssl_ciphers ECDHE+AESGCM:DHE+AESGCM:ECDHE+RSA+SHA256:DHE+RSA+SHA256:!AES128;
{% else %}
Expand Down
4 changes: 4 additions & 0 deletions make/photon/prepare/templates/portal/nginx.conf.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,11 @@ http {
ssl_certificate /etc/harbor/tls/portal.crt;
ssl_certificate_key /etc/harbor/tls/portal.key;

{% if ssl_protocols is defined %}
ssl_protocols {{ssl_protocols}};
{% else %}
ssl_protocols TLSv1.2 TLSv1.3;
{% endif %}
{% if strong_ssl_ciphers %}
ssl_ciphers ECDHE+AESGCM:DHE+AESGCM:ECDHE+RSA+SHA256:DHE+RSA+SHA256:!AES128;
{% else %}
Expand Down
7 changes: 6 additions & 1 deletion make/photon/prepare/utils/configs.py
Original file line number Diff line number Diff line change
Expand Up @@ -299,11 +299,16 @@ def parse_yaml_config(config_file_path, with_trivy):
external_database=config_dict['external_database'])
else:
config_dict['internal_tls'] = InternalTLS()

# ssl_protocols config
if https_config:
config_dict['ssl_protocols'] = https_config.get('ssl_protocols')

# the configure item apply to internal and external tls communication
# for compatibility, user could configure the strong_ssl_ciphers either in https section or under internal_tls section,
# but it is more reasonable to configure it in https_config
if https_config:
config_dict['strong_ssl_ciphers'] = https_config.get('strong_ssl_ciphers')
config_dict['strong_ssl_ciphers'] = https_config.get('strong_ssl_ciphers')
else:
config_dict['strong_ssl_ciphers'] = False

Expand Down
1 change: 1 addition & 0 deletions make/photon/prepare/utils/nginx.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ def render_nginx_template(config_dict):
ssl_cert_key=SSL_CERT_KEY_PATH,
internal_tls=config_dict['internal_tls'],
metric=config_dict['metric'],
ssl_protocols=config_dict['ssl_protocols'],
strong_ssl_ciphers=config_dict['strong_ssl_ciphers'],
ip_family=config_dict['ip_family'])
location_file_pattern = CUSTOM_NGINX_LOCATION_FILE_PATTERN_HTTPS
Expand Down
1 change: 1 addition & 0 deletions make/photon/prepare/utils/portal.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,6 @@ def prepare_portal(config_dict):
ip_family=config_dict['ip_family'],
uid=DEFAULT_UID,
gid=DEFAULT_GID,
ssl_protocols=config_dict['ssl_protocols'],
strong_ssl_ciphers=config_dict['strong_ssl_ciphers']
)

0 comments on commit 2ee5dc6

Please sign in to comment.