From 7648d294bfe06f335d1c77bad2d662fc0ab0914b Mon Sep 17 00:00:00 2001 From: Ricardo Dias Date: Tue, 9 Apr 2019 13:42:57 +0100 Subject: [PATCH] mgr/dashboard: added CLI commands to set SSL certificate and key Fixes: https://tracker.ceph.com/issues/39123 Signed-off-by: Ricardo Dias --- src/pybind/mgr/dashboard/module.py | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/src/pybind/mgr/dashboard/module.py b/src/pybind/mgr/dashboard/module.py index 3f66790bc6a..868ccdb557e 100644 --- a/src/pybind/mgr/dashboard/module.py +++ b/src/pybind/mgr/dashboard/module.py @@ -14,7 +14,7 @@ import threading import time from uuid import uuid4 from OpenSSL import crypto, SSL -from mgr_module import MgrModule, MgrStandbyModule, Option +from mgr_module import MgrModule, MgrStandbyModule, Option, CLIWriteCommand from mgr_util import get_default_addr try: @@ -405,6 +405,30 @@ class Module(MgrModule, CherryPyConfig): logger.info('Stopping engine...') self.shutdown_event.set() + @CLIWriteCommand("dashboard set-ssl-certificate", + "name=mgr_id,type=CephString,req=false") + def set_ssl_certificate(self, mgr_id=None, inbuf=None): + if inbuf is None: + return -errno.EINVAL, '',\ + 'Please specify the certificate file with "-i" option' + if mgr_id is not None: + self.set_store('{}/crt'.format(mgr_id), inbuf) + else: + self.set_store('crt', inbuf) + return 0, 'SSL certificate updated', '' + + @CLIWriteCommand("dashboard set-ssl-certificate-key", + "name=mgr_id,type=CephString,req=false") + def set_ssl_certificate_key(self, mgr_id=None, inbuf=None): + if inbuf is None: + return -errno.EINVAL, '',\ + 'Please specify the certificate key file with "-i" option' + if mgr_id is not None: + self.set_store('{}/key'.format(mgr_id), inbuf) + else: + self.set_store('key', inbuf) + return 0, 'SSL certificate key updated', '' + def handle_command(self, inbuf, cmd): # pylint: disable=too-many-return-statements res = handle_option_command(cmd) -- 2.39.5