Skip to content

x/crypto/ssh: ParsePrivateKey gives unintuitive error message for encrypted keys #6650

Closed
@rogpeppe

Description

@rogpeppe
key, err := ioutil.ReadFile("/home/rog/.ssh/id_rsa")
    if err != nil {
        log.Fatal(err)
    }
    _, err = ssh.ParsePrivateKey(key)
    if err != nil {
        log.Fatalf("cannot parse ssh private key: %v", err)
    }

ParsePrivateKey fails with an error like this:

asn1: structure error: tags don't match (16 vs {class:1 tag:28 length:11
isCompound:true}) {optional:false explicit:false application:false
defaultValue:<nil> tag:<nil> stringType:0 set:false omitEmpty:false}
pkcs1PrivateKey @2

I'd expect to see an error that complains about the fact
that the private key is encrypted.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions