Skip to content

Support PKCS#8 #1090

@wertzui

Description

@wertzui

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions