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

ValueError on installation of Github Integration #12953

Closed
1 of 2 tasks
rics3n opened this issue Apr 26, 2019 · 7 comments
Closed
1 of 2 tasks

ValueError on installation of Github Integration #12953

rics3n opened this issue Apr 26, 2019 · 7 comments

Comments

@rics3n
Copy link

rics3n commented Apr 26, 2019

Important Details

How are you running Sentry?

  • On-Premise docker [Version 9.1.1]
  • Saas (sentry.io)

Description

Unable to install the Github Integration. The error seems to happen when the private key is loaded. sentry config get github-app.private-key is showing the correct key with newlines separated by \n as described in the docs and in this issue.

Steps to Reproduce

  1. Follow the guide from the docs to configure the Github Integration
  2. Install Github Integration trough settings/<orga>/integrations/
  3. In the Github popup click on install
  4. Github is redirecting to sentry and sentry throws the following error

Stacktrace of the error:

  File "/usr/local/lib/python2.7/site-packages/sentry/pipeline/__init__.py", line 207, in current_step
    return self.finish_pipeline()
  File "/usr/local/lib/python2.7/site-packages/sentry/integrations/pipeline.py", line 41, in finish_pipeline
    data = self.provider.build_integration(self.state.data)
  File "/usr/local/lib/python2.7/site-packages/sentry/integrations/github/integration.py", line 234, in build_integration
    identity['access_token'], state['installation_id'])
  File "/usr/local/lib/python2.7/site-packages/sentry/integrations/github/integration.py", line 207, in get_installation_info
    'Authorization': 'Bearer %s' % get_jwt(),
  File "/usr/local/lib/python2.7/site-packages/sentry/integrations/github/utils.py", line 27, in get_jwt
    return jwt.encode(payload, github_private_key, algorithm='RS256')
  File "/usr/local/lib/python2.7/site-packages/jwt/api_jwt.py", line 56, in encode
    json_payload, key, algorithm, headers, json_encoder
  File "/usr/local/lib/python2.7/site-packages/jwt/api_jws.py", line 102, in encode
    key = alg_obj.prepare_key(key)
  File "/usr/local/lib/python2.7/site-packages/jwt/algorithms.py", line 207, in prepare_key
    key = load_pem_public_key(key, backend=default_backend())
  File "/usr/local/lib/python2.7/site-packages/cryptography/hazmat/primitives/serialization/base.py", line 20, in load_pem_public_key
    return backend.load_pem_public_key(data)
  File "/usr/local/lib/python2.7/site-packages/cryptography/hazmat/backends/openssl/backend.py", line 1071, in load_pem_public_key
    self._handle_key_loading_error()
  File "/usr/local/lib/python2.7/site-packages/cryptography/hazmat/backends/openssl/backend.py", line 1329, in _handle_key_loading_error
    raise ValueError("Could not deserialize key data.")
ValueError: Could not deserialize key data.

What you expected to happen

The github integration should be installed successfully.

@markstory
Copy link
Member

Sounds like you key is invalid or corrupt.

@rics3n
Copy link
Author

rics3n commented Apr 26, 2019

This was also my first gut feeling. I created multiple keys in my github app and converted them all to \n format. Also tried without it but no luck.

This is the format which I understand should work.

github-app.private-key: "-----BEGIN RSA PRIVATE KEY-----\n<PRIVATE KEY LINE 1>\n....\n<PRIVATE KEY LINE N>\n-----END RSA PRIVATE KEY-----"

Can anyone confirm that it works with version 9.1.1?

@chrisella
Copy link

chrisella commented Apr 28, 2019

Same problem here.

ValueError: Could not deserialize key data.

In the callback from adding the GitHub app. Any updates would be appreciated.
I've also tried with 2 keys, each with newlines converted to no avail.

@chrisella
Copy link

Ah finally got it working, the difference this time was I made sure the private string had a trailing \n
Give that a go, maybe you'll be as lucky.

@rics3n
Copy link
Author

rics3n commented Apr 29, 2019

Thanks for the answer, but no luck for me. I now also executed the code from utils.py inside a python interpreter session with the key returned by sentry config get github-app.private-key. The error did not happen with or without the trailing \n. The jwt token could be generated without a problem.

@el7cosmos
Copy link

I got it working by replacing single quote with double quote for the config value

github-app.private-key: '-----BEGIN RSA PRIVATE KEY-----\n...\n-----END RSA PRIVATE KEY-----\n'
github-app.private-key: "-----BEGIN RSA PRIVATE KEY-----\n...\n-----END RSA PRIVATE KEY-----\n"

@BYK
Copy link
Member

BYK commented Jul 5, 2019

Closing as this looks like a configuration error and not a bug.

@BYK BYK closed this as completed Jul 5, 2019
@github-actions github-actions bot locked and limited conversation to collaborators Dec 18, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants