#7033 vault: TypeError: ... is not JSON serializable
Closed: fixed 6 years ago Opened 6 years ago by mbasti.

In python3 vault commands are failing on JSON encoding error in pki python module

Traceback (most recent call last):
  File "/usr/lib/python3.5/site-packages/ipaserver/rpcserver.py", line 367, in wsgi_execute
    result = command(*args, **options)
  File "/usr/lib/python3.5/site-packages/ipalib/frontend.py", line 447, in __call__
    return self.__do_call(*args, **options)
  File "/usr/lib/python3.5/site-packages/ipalib/frontend.py", line 475, in __do_call
    ret = self.run(*args, **options)
  File "/usr/lib/python3.5/site-packages/ipalib/frontend.py", line 797, in run
    return self.execute(*args, **options)
  File "/usr/lib/python3.5/site-packages/ipaserver/plugins/vault.py", line 1075, in execute
    nonce_iv=nonce,
  File "/usr/lib/python3.5/site-packages/pki/__init__.py", line 304, in handler
    return fn_call(inst, *args, **kwargs)
  File "/usr/lib/python3.5/site-packages/pki/key.py", line 799, in archive_encrypted_data
    return self.submit_request(request)
  File "/usr/lib/python3.5/site-packages/pki/__init__.py", line 304, in handler
    return fn_call(inst, *args, **kwargs)
  File "/usr/lib/python3.5/site-packages/pki/key.py", line 579, in submit_request
    sort_keys=True)
  File "/usr/lib64/python3.5/json/__init__.py", line 237, in dumps
    **kw).encode(obj)
  File "/usr/lib64/python3.5/json/encoder.py", line 198, in encode
    chunks = self.iterencode(o, _one_shot=True)
  File "/usr/lib64/python3.5/json/encoder.py", line 256, in iterencode
    return _iterencode(o, 0)
  File "/usr/lib/python3.5/site-packages/pki/encoder.py", line 92, in default
    return json.JSONEncoder.default(self, obj)
  File "/usr/lib64/python3.5/json/encoder.py", line 179, in default
    raise TypeError(repr(o) + " is not JSON serializable")
TypeError: b'EVt0v9p1qGAw9hfrsF9v1A==' is not JSON serializable

This is caused by call in ipaserver/plugins/vault.py

            kra_client.keys.archive_encrypted_data(
                client_key_id,
                pki.key.KeyClient.PASS_PHRASE_TYPE,
                wrapped_vault_data,
                wrapped_session_key,
                algorithm_oid=DES_EDE3_CBC_OID,
                nonce_iv=nonce,
            )

Param values

wrapped_vault_data: b'\\x11[t\\xbf\\xdau\\xa8`0\\xf6\\x17\\xeb\\xb0_o\\xd4'
wrapped_session_key: b'\\xa5;x\\x14\\x11\\xf2\\xf9\\xfe\\x13^\\xdf\\xda\\xb8[}\\t\\xaa\\xba(\\x82\\x90\\xecM\\xb1\\x07\\xde\\xe9P\\xf4\\x
d1\\x0ezh\\x0e/w\\x8e\\xea\\x8c\\x17[\\xf3(\\xd1\\x07T\\xffJ\\xe1\\xea\\xc9h&#\\xda}.#\\xc4\\xa9\\xd76\\x8a\\xe9\\x1d\\xfc;\\x88/x\\x98#\\x9d\\xd50\\x88$\\xe4=t\\n\\xd9\\xe5\\xbe\\r\\x83\\x03c\\xbb.IN\\xf0\\th#\
\x9bj\\xd2S|\\xe6m\\xff\\x00[\\xa2;j@8 ii\\x00TU~\\r\\x19\\x7f\\x84\\xde\\x19\\xea\\xa7\\xdaO\\xc1\\xda%Q]E\\xb9yA5=\\x1f\\xd4\\x08\\xa9\\x85\\x87\\x9an\\xf5\\xc1#Ih\\xf8\\x05\\xb4%\\x01o\\\\\\xf1\\xce\\x80\\xf8
\\x19\\xb0Gv!|\\xd7\\xd8\\x1e\\x9b\\xb3^\\xe3\\xca\\x00\\xc6\\xcd\\x9d^\\xdd\\x89\\x00+|&)\\x17L\\rG\\x87Tm\\x90\\xc5\\x0cx\\xa1#eA\\xb0}QT\\ru\\x10\\xff\\xba\\x84\\x7fP\\x14\\x91<\\xe9\\xfb;\\x8c.\\x8est\\x969\
\x8d\\tS\\xf7L+\\xe1\\xa8\\xe7jy4P\\xc2\\x98\\xe2\\xedk6\\xfd\\xad\\x8b-]\\xf0\\xfd\\xee'
nonce: b'\\xfa\\xdd\\xed\\x1c\\x92g\\t\\xd1'
client_key_id: 'ipa:/services/HTTP/server.example.com@EXAMPLE.TEST/test_vault'

Metadata Update from @mbasti:
- Issue tagged with: py3, tracker

6 years ago

Metadata Update from @mbasti:
- Issue assigned to mbasti

6 years ago

Metadata Update from @mbasti:
- Custom field external_tracker adjusted to https://pagure.io/dogtagpki/issue/2746

6 years ago

Metadata Update from @pvoborni:
- Issue set to the milestone: FreeIPA 4.6

6 years ago

Metadata Update from @mbasti:
- Issue assigned to stlaz (was: mbasti)

6 years ago

master:

  • 9cead4d py3: fix vault public key decoding

Metadata Update from @tkrizek:
- Issue set to the milestone: FreeIPA 4.6.1 (was: FreeIPA 4.6)

6 years ago

Metadata Update from @tkrizek:
- Issue set to the milestone: FreeIPA 4.6.2 (was: FreeIPA 4.6.1)

6 years ago

Metadata Update from @cheimes:
- Issue assigned to cheimes (was: stlaz)

6 years ago

master:

Metadata Update from @cheimes:
- Issue close_status updated to: fixed
- Issue status updated to: Closed (was: Open)

6 years ago

ipa-4-6:

Login to comment on this ticket.

Metadata