Skip to content

Support PKCS#8 #1090

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

Closed
wertzui opened this issue Feb 28, 2023 · 0 comments · Fixed by #1496
Closed

Support PKCS#8 #1090

wertzui opened this issue Feb 28, 2023 · 0 comments · Fixed by #1496

Comments

@wertzui
Copy link

wertzui commented Feb 28, 2023

At the Moment only PKCS#1 RSA keys are supported.
Those begin with -----BEGIN RSA PRIVATE KEY-----

However PKCS#8 Keys are not supported.
Those begin with -----BEGIN PRIVATE KEY-----

I stumbled across this problem when using openssl to generate a key.
By default openssl will write using the PKCS#8 format.
Only if you give it the -traditional flag, it will write in PKCS#1 format.

The error I was getting with PKCS#8 was the following one, because the RegEx that is used to extract the algorithm did not match, because the algorithm is not present in -----BEGIN PRIVATE KEY-----.

Renci.SshNet.Common.SshException: Invalid private key file.
   at Renci.SshNet.PrivateKeyFile.Open(Stream privateKey, String passPhrase)
   at Renci.SshNet.PrivateKeyFile..ctor(Stream privateKey)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant