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

could not parse private key: Invalid Key: Key must be PEM encoded PKCS1 or PKCS8 private key #100

Closed
cswendrowski opened this issue Jul 15, 2019 · 2 comments · Fixed by #104
Labels
documentation The issue is due to bad documentation

Comments

@cswendrowski
Copy link

I am using the latest Dockerhub image for policy-bot and cannot successfully start the container to the error Error: failed to initialize Github app client: could not parse private key: Invalid Key: Key must be PEM encoded PKCS1 or PKCS8 private key

I have attempted to use various formats for the .pem generated by Github, such as:

private_key: "-----BEGIN RSA PRIVATE KEY-----
MIIEpAIBAAKCAQEArjfzbTEsi4kxQTi73Weh9zKmxCZ7nu3osRUM7ovd1XEnRK6z
. . .
HH3A+JuNscHTnGjTm2dmaTjTyEnCQxNQ8Z0NSxKVytOAymxXiiSyxg==
-----END RSA PRIVATE KEY-----"

Putting it all on one line or removing the -----BEGIN RSA PRIVATE KEY----- and -----END RSA PRIVATE KEY----- does not work as well.

I took a look through the code to try and see what I was doing wrong, but unfortunately I have never worked with Go before and only got as far as determining that you are somewhere converting the base64 content into a byte array

@asvoboda
Copy link
Member

asvoboda commented Jul 15, 2019

Hey @cswendrowski

I think the docs could use some updates here, but it should be an issue of formatting the private key with the right indentation:

github:
  app:
    private_key: |
      -----BEGIN RSA PRIVATE KEY-----
      ...
      -----END RSA PRIVATE KEY-----

Note that the | character denotes this is a multi-line yaml string.

@cswendrowski
Copy link
Author

cswendrowski commented Jul 15, 2019

Thanks for the quick response!

That did the trick, this section now loads correctly:

    # The private key of the GitHub app
    private_key: |
      -----BEGIN RSA PRIVATE KEY-----
      MIIEpAIBAAKCAQEArjfzbTEsi4kxQTi73Weh9zKmxCZ7nu3osRUM7ovd1XEnRK6z
      . . .
      HH3A+JuNscHTnGjTm2dmaTjTyEnCQxNQ8Z0NSxKVytOAymxXiiSyxg==
      -----END RSA PRIVATE KEY-----
    oauth:

Thanks kindly

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation The issue is due to bad documentation
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants