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

crypto/tls: better error message for X509KeyPair #11092

Closed
taylorhughes opened this issue Jun 5, 2015 · 2 comments
Closed

crypto/tls: better error message for X509KeyPair #11092

taylorhughes opened this issue Jun 5, 2015 · 2 comments
Assignees
Milestone

Comments

@taylorhughes
Copy link

@taylorhughes taylorhughes commented Jun 5, 2015

  1. What did I do?

    // mixed up order of key and cert:
    http.ListenAndServeTLS(..., key, cert, ...)

  2. What happened?

    This resulted in the following cryptic error message:

    crypto/tls: failed to parse certificate PEM data

  3. What did I expect?

    I spent about an hour debugging various PEM format possibilities before finding the mixup.

    An error message explaining that the type of PEM block was unexpected would have saved me some time:

    crypto/tls: failed to parse certificate PEM data, expected type "CERTIFICATE", got "PRIVATE KEY"

Related issue: #7042

@adg adg changed the title better error message for X509KeyPair() in crypto/tls/tls.go crypto/tls: better error message for X509KeyPair Jun 5, 2015
@adg

This comment has been minimized.

Copy link
Contributor

@adg adg commented Jun 5, 2015

It's more that the CERTIFICATE block wasn't found. Assigning to @agl

@adg adg assigned agl Jun 5, 2015
@ianlancetaylor ianlancetaylor added this to the Go1.6 milestone Jun 6, 2015
@gopherbot

This comment has been minimized.

Copy link

@gopherbot gopherbot commented Aug 30, 2015

CL https://golang.org/cl/14054 mentions this issue.

@agl agl closed this in be16001 Sep 30, 2015
@golang golang locked and limited conversation to collaborators Oct 4, 2016
FiloSottile pushed a commit to FiloSottile/go that referenced this issue Oct 12, 2018
This change causes the types of skipped PEM blocks to be recorded when
no certificate or private-key data is found in a PEM input. This allows
for better error messages to be return in the case of common errors like
switching the certifiate and key inputs to X509KeyPair.

Fixes golang#11092

Change-Id: Ifc155a811cdcddd93b5787fe16a84c972011f2f7
Reviewed-on: https://go-review.googlesource.com/14054
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
FiloSottile pushed a commit to FiloSottile/go that referenced this issue Oct 12, 2018
This change causes the types of skipped PEM blocks to be recorded when
no certificate or private-key data is found in a PEM input. This allows
for better error messages to be return in the case of common errors like
switching the certifiate and key inputs to X509KeyPair.

Fixes golang#11092

Change-Id: Ifc155a811cdcddd93b5787fe16a84c972011f2f7
Reviewed-on: https://go-review.googlesource.com/14054
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
5 participants
You can’t perform that action at this time.