From 648812ee115e389d702d2751907adcf70ecef5e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20Wolfsj=C3=A4ger?= Date: Fri, 1 Apr 2022 17:48:04 +0200 Subject: [PATCH] Fixed reading SSL settings from rabbitmqadmin config file Fixed reading boolean values from rabbitmqadmin config file --- deps/rabbitmq_management/bin/rabbitmqadmin | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/deps/rabbitmq_management/bin/rabbitmqadmin b/deps/rabbitmq_management/bin/rabbitmqadmin index 66453106085a..cc7fbd866cab 100755 --- a/deps/rabbitmq_management/bin/rabbitmqadmin +++ b/deps/rabbitmq_management/bin/rabbitmqadmin @@ -331,6 +331,8 @@ default_options = {"hostname": "localhost", "username": "guest", "password": "guest", "ssl": False, + "ssl_insecure": False, + "ssl_disable_hostname_verification": False, "request_timeout": 120, "verbose": True, "format": "table", @@ -393,9 +395,9 @@ def make_parser(): add("--ssl-ca-cert-file", dest="ssl_ca_cert_file", help="PEM format CA certificate file for SSL") add("--ssl-disable-hostname-verification", dest="ssl_disable_hostname_verification", - help="Disables peer hostname verification", default=False, action="store_true") + help="Disables peer hostname verification", action="store_true") add("-k", "--ssl-insecure", dest="ssl_insecure", - help="Disables all SSL validations like curl's '-k' argument", default=False, action="store_true") + help="Disables all SSL validations like curl's '-k' argument", action="store_true") add("-t", "--request-timeout", dest="request_timeout", help="HTTP request timeout in seconds", type="int") add("-f", "--format", dest="format", @@ -470,13 +472,14 @@ def merge_config_file_options(cli_options, final_options): assert_usage(False, msg) else: for key, section_val in section_settings.items(): - # special case --ssl - if key == 'ssl': + # if CLI options contain this key, do not set it from the config file + if getattr(cli_options, key) is not None: + continue + # special case for boolean values + if section_val == "True" or section_val == "False": setattr(final_options, key, section_val == "True") else: - # if CLI options do not contain this key, set it from the config file - if getattr(cli_options, key) is None: - setattr(final_options, key, section_val) + setattr(final_options, key, section_val) return final_options def expand_base_uri_options(cli_options, final_options):