diff --git a/vmware_nsx/plugins/nsx_v/md_proxy.py b/vmware_nsx/plugins/nsx_v/md_proxy.py index ef9dca2378..af2a104c62 100644 --- a/vmware_nsx/plugins/nsx_v/md_proxy.py +++ b/vmware_nsx/plugins/nsx_v/md_proxy.py @@ -658,8 +658,8 @@ class NsxVMetadataProxyHandler(object): # When shared proxy is configured, insert authentication string if cfg.CONF.nsxv.metadata_shared_secret: signature = hmac.new( - cfg.CONF.nsxv.metadata_shared_secret, - edge_id, + bytearray(cfg.CONF.nsxv.metadata_shared_secret, 'ascii'), + bytearray(edge_id, 'ascii'), hashlib.sha256).hexdigest() sign_app_rule = nsxv_lb.NsxvLBAppRule( 'insert-auth', diff --git a/vmware_nsx/shell/admin/plugins/nsxv/resources/metadata.py b/vmware_nsx/shell/admin/plugins/nsxv/resources/metadata.py index 4d238c0961..2db78fac39 100644 --- a/vmware_nsx/shell/admin/plugins/nsxv/resources/metadata.py +++ b/vmware_nsx/shell/admin/plugins/nsxv/resources/metadata.py @@ -159,9 +159,10 @@ def update_shared_secret(resource, event, trigger, **kwargs): virt.del_app_rule('insert-auth') if cfg.CONF.nsxv.metadata_shared_secret: - signature = hmac.new(cfg.CONF.nsxv.metadata_shared_secret, - edge_id, - hashlib.sha256).hexdigest() + signature = hmac.new( + bytearray(cfg.CONF.nsxv.metadata_shared_secret, 'ascii'), + bytearray(edge_id, 'ascii'), + hashlib.sha256).hexdigest() sign = 'reqadd X-Metadata-Provider-Signature:' + signature sign_app_rule = nsxv_lb.NsxvLBAppRule('insert-auth', sign) virt.add_app_rule(sign_app_rule)