Uploaded image for project: 'Libcloud'
  1. Libcloud
  2. LIBCLOUD-610

GCE Driver with bad private key path generates unintuitive error message

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Minor
    • Resolution: Fixed
    • None
    • None
    • Compute

    Description

      When you pass a key to the GCE driver and the path doesn't exist, it ends up passing the buck down to PyCrypto, because it assumes that it isn't a keypath. Relevant lines are here (snipped from `_init_` method of `GoogleBaseAuthConnection`):

      gce.py
              keypath = os.path.expanduser(key)
              is_file_path = os.path.exists(keypath) and os.path.isfile(keypath)
              if is_file_path:
                  with open(keypath, 'r') as f:
                      key = f.read()
              super(GoogleServiceAcctAuthConnection, self).__init__(
                  user_id, key, *args, **kwargs)
      

      The problem is the keypath doesn't exist (and obviously it's not a file), so instead of a nice error message saying 'invalid file path', you get a ValueError from PyCrypto saying 'ValueError: RSA key format is not supported' which is problematic especially because you also get this error if you have the wrong version of PyCrypto installed. Given that PyCrypto actually expects bytes, I think it makes sense for libcloud to be responsible for this error.

      I encountered this using salt and there's an open issue to deal with it on the salt end here - https://github.com/saltstack/salt/pull/15589

      Attachments

        Activity

          People

            erjohnso Eric Johnson
            jtratner Jeff Tratner
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: