mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
fix 'APIC Error 403: padding check failed' in python3 (#55150)
* fix 'APIC Error 403: padding check failed' in python3 With python2 the APIC-Request-Signature is filled in correctly APIC-Request-Signature=aAvxASu... But with python3 the string format method seems to add the encoding to the output, causing a padding error: APIC-Request-Signature=b'lFmHWvwW4dr... Reproduce: # -*- coding: utf-8 -*- import base64 a = base64.b64encode(b'\u0001') b = '%s' % a print(b) ======= python --version; python test.py Python 2.7.16 :: Anaconda, Inc. XHUwMDAx Python 3.6.3 :: Anaconda, Inc. b'XHUwMDAx' * Ensure we use native strings
This commit is contained in:
parent
f7ed194bc9
commit
b24c037f62
1 changed files with 2 additions and 2 deletions
|
@ -39,7 +39,7 @@ from copy import deepcopy
|
||||||
from ansible.module_utils.parsing.convert_bool import boolean
|
from ansible.module_utils.parsing.convert_bool import boolean
|
||||||
from ansible.module_utils.six.moves.urllib.parse import urlencode
|
from ansible.module_utils.six.moves.urllib.parse import urlencode
|
||||||
from ansible.module_utils.urls import fetch_url
|
from ansible.module_utils.urls import fetch_url
|
||||||
from ansible.module_utils._text import to_bytes
|
from ansible.module_utils._text import to_bytes, to_native
|
||||||
|
|
||||||
# Optional, only used for APIC signature-based authentication
|
# Optional, only used for APIC signature-based authentication
|
||||||
try:
|
try:
|
||||||
|
@ -267,7 +267,7 @@ class ACIModule(object):
|
||||||
self.headers['Cookie'] = 'APIC-Certificate-Algorithm=v1.0; ' +\
|
self.headers['Cookie'] = 'APIC-Certificate-Algorithm=v1.0; ' +\
|
||||||
'APIC-Certificate-DN=%s; ' % sig_dn +\
|
'APIC-Certificate-DN=%s; ' % sig_dn +\
|
||||||
'APIC-Certificate-Fingerprint=fingerprint; ' +\
|
'APIC-Certificate-Fingerprint=fingerprint; ' +\
|
||||||
'APIC-Request-Signature=%s' % sig_signature
|
'APIC-Request-Signature=%s' % to_native(sig_signature)
|
||||||
|
|
||||||
def response_json(self, rawoutput):
|
def response_json(self, rawoutput):
|
||||||
''' Handle APIC JSON response output '''
|
''' Handle APIC JSON response output '''
|
||||||
|
|
Loading…
Reference in a new issue