python-3.xaws-lambdapyjks

Upgrade AWS lambda python 3.6 to 3.8 causing issues with pyjks


I have lambda function that works in Python3.6. I tried to update to 3.8 and I am getting below exception when running with pyjks library

def _load_keystores(data, passCode):
  logger.info('Load the keystore information')
  return jks.KeyStore.loads(data, passCode)

Exception

[ERROR] TypeError: 'NoneType' object is not subscriptable
Traceback (most recent call last):
  File "/var/task/service_setup.py", line 40, in lambda_handler
    create_keystore(event, secrets_data, config_data, 
     keystore_prefix='secretKey')
  File "/var/task/keystore_compute.py", line 44, in _load_keystores
     return jks.KeyStore.loads(data, passCode)
  File "/var/task/jks/jks.py", line 484, in loads
     magic_number = data[:4]

Solution

  • KeyStore.loads() accepts a byte string as a data parameter, but your error indicates that None was passed instead. Check the type(data) and verify that it's bytes before passing it to KeyStore.loads().

    It's impossible to say from your example code where data is coming from, and how the version upgrade could affect it, but you are getting None instead of the byte string in it.