Skip to content

Commit e2e550e

Browse files
committed
REST server cert configurations
REST and telemetry servers were using "DEVICE_METADATA|x509" table for server certificate configurations. This table has been deprecated now. Enhanced REST server startup script to read server certificate file path configurations from REST_SERVER table. Three more attributes - server_crt, server_key and ca_crt are introduced as described in sonic-net/SONiC#550. For backard compatibility, certificate configurations are read from old "DEVICE_METADATA|x509" table if they (server_crt, server_key and ca_crt) are not present in REST_SERVER table. Fixes bug sonic-net#4291 Signed-off-by: Sachin Holla <sachin.holla@broadcom.com>
1 parent f31eabb commit e2e550e

1 file changed

Lines changed: 8 additions & 8 deletions

File tree

dockers/docker-sonic-mgmt-framework/rest-server.sh

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,23 @@
22

33
# Startup script for SONiC Management REST Server
44

5-
SERVER_PORT=
6-
LOG_LEVEL=
7-
CLIENT_AUTH=
8-
SERVER_CRT=
9-
SERVER_KEY=
10-
CA_CERT=
11-
125
# Read basic server settings from REST_SERVER|default entry
136
HAS_REST_CONFIG=$(sonic-cfggen -d -v "1 if REST_SERVER and REST_SERVER['default']")
147
if [ "$HAS_REST_CONFIG" == "1" ]; then
158
SERVER_PORT=$(sonic-cfggen -d -v "REST_SERVER['default']['port']")
169
CLIENT_AUTH=$(sonic-cfggen -d -v "REST_SERVER['default']['client_auth']")
1710
LOG_LEVEL=$(sonic-cfggen -d -v "REST_SERVER['default']['log_level']")
11+
12+
SERVER_CRT=$(sonic-cfggen -d -v "REST_SERVER['default']['server_crt']")
13+
SERVER_KEY=$(sonic-cfggen -d -v "REST_SERVER['default']['server_key']")
14+
CA_CRT=$(sonic-cfggen -d -v "REST_SERVER['default']['ca_crt']")
15+
fi
16+
17+
if [[ -z $SERVER_CRT ]] && [[ -z $SERVER_KEY ]] && [[ -z $CA_CRT ]]; then
18+
HAS_X509_CONFIG=$(sonic-cfggen -d -v "1 if DEVICE_METADATA and DEVICE_METADATA['x509']")
1819
fi
1920

2021
# Read certificate file paths from DEVICE_METADATA|x509 entry.
21-
HAS_X509_CONFIG=$(sonic-cfggen -d -v "1 if DEVICE_METADATA and DEVICE_METADATA['x509']")
2222
if [ "$HAS_X509_CONFIG" == "1" ]; then
2323
SERVER_CRT=$(sonic-cfggen -d -v "DEVICE_METADATA['x509']['server_crt']")
2424
SERVER_KEY=$(sonic-cfggen -d -v "DEVICE_METADATA['x509']['server_key']")

0 commit comments

Comments
 (0)