Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

On GAE: "pyOpenSSL must be installed to load a private key" #1487

Closed
kvdb opened this issue Feb 18, 2016 · 8 comments
Closed

On GAE: "pyOpenSSL must be installed to load a private key" #1487

kvdb opened this issue Feb 18, 2016 · 8 comments
Assignees
Labels
api: core auth type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.

Comments

@kvdb
Copy link

kvdb commented Feb 18, 2016

I've tried gcloud 0.10.0 on the local dev_appserver.py. While I've got the same problem as reported in #1436, I've got an additional exception too:

File "/x/libs/gcloud/storage/blob.py", line 233, in generate_signed_url
  generation=generation)
File "/x/libs/gcloud/credentials.py", line 379, in generate_signed_url
  string_to_sign)
File "/x/libs/gcloud/credentials.py", line 267, in _get_signed_query_params
  signature_bytes = _get_signature_bytes(credentials, string_to_sign)
File "/x/libs/gcloud/credentials.py", line 215, in _get_signature_bytes
  pkey = _get_pem_key(credentials)
File "/x/libs/gcloud/credentials.py", line 191, in _get_pem_key
  'pyOpenSSL must be installed to load a private key')

EnvironmentError: pyOpenSSL must be installed to load a private key

That problem seems to be related to PR #1338.

@dhermes
Copy link
Contributor

dhermes commented Feb 19, 2016

This is a code-path I didn't anticipate, since in production GAE the code would just use

Do you have custom code for using service accounts with dev_appserver? I've been meaning to (#574) document how this works but have never tried it.

Also, I need to just push this functionality into oauth2client and not depend (at least not in an explicit way) on any of the Crypto libraries. oauth2client would be able to do this just fine with PyCrypto, but only ServiceAccountCredentials implements sign_blob (as of 2.0.0) so it's as simple as implementing that method on the GCE and GAE credentials classes and then deleting all of our custom code.

@kvdb
Copy link
Author

kvdb commented Feb 19, 2016

Not sure if I understand you correctly, but we're using this code in GAE to setup GCS. Hope it helps:

    project = app_identity.get_application_id()                             
    client = storage.Client.from_service_account_json(                      
        'service_account.json', project)                                           
    bucket = client.get_bucket(bucket)           
    blob = bucket.blob(fname)                                         

We're not using the appidentity parameters for dev_appserver.

@dhermes
Copy link
Contributor

dhermes commented Feb 19, 2016

Got it. I figured you were using

from oauth2client.client import GoogleCredentials
credentials = GoogleCredentials.get_application_default()
# OR
from oauth2client.contrib.appengine import AppAssertionCredentials
credentials = AppAssertionCredentials([])

RE: "We're not using the appidentity parameters for dev_appserver."

Does this mean you use 'service_account.json' in the dev_appserver but use the GAE service account in production?

@theacodes
Copy link
Contributor

Does this mean you use 'service_account.json' in the dev_appserver but use the GAE service account in production?

I wrote lots of projects that used service_account.json in both environments, as it's currently the only way to do domain-wide delegation of authority.

@dhermes
Copy link
Contributor

dhermes commented Feb 19, 2016

Yeah I am going to push our auth / signing stuff upstream today (finally). Won't drop pyOpenSSL from setup.py but this will at least keep GAE from being b0rken.

@dhermes dhermes added type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. api: core auth labels Feb 19, 2016
@dhermes
Copy link
Contributor

dhermes commented Feb 19, 2016

FYI once googleapis/oauth2client#421 is in, we can tear out most of the auth code in gcloud-python. Yay (sort of!)

@kvdb
Copy link
Author

kvdb commented Mar 10, 2016

@dhermes: we're using the same service_account.json in dev_appserver as well as in production.

@dhermes
Copy link
Contributor

dhermes commented Mar 11, 2016

@kvdb This should work just fine now. Please let me know if it does not.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: core auth type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Projects
None yet
Development

No branches or pull requests

3 participants