Skip to content

crypto/tls: fails to parse certain PEM files with multiple blocks #3986

Description

@hoisie
What steps will reproduce the problem?
http://play.golang.org/p/_v-ah5iWAR

What is the expected output?
No error

What do you see instead?
crypto/tls: failed to parse key: ASN.1 structure error: tags don't match (2 vs {class:0
tag:16 length:725 isCompound:true}) {optional:false explicit:false application:false
defaultValue:<nil> tag:<nil> stringType:0 set:false omitEmpty:false} int @4

Which compiler are you using (5g, 6g, 8g, gccgo)?
6g

Which operating system are you using?
OSX 10.7.4

Which version are you using?  (run 'go version')
go version go1.0.2

Please provide any additional information below.

A pem file with the following order is successfully parse:

-----BEGIN RSA PRIVATE KEY----- 
... key ...
-----END RSA PRIVATE KEY----- 
-----BEGIN CERTIFICATE----- 
... cert ...
-----END CERTIFICATE----- 

But one with the order reversed does not:
-----BEGIN CERTIFICATE----- 
... cert ...
-----END CERTIFICATE----- 
-----BEGIN RSA PRIVATE KEY----- 
... key ...
-----END RSA PRIVATE KEY-----

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions