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

Fix nil pointer panic in ParseCSRPEM #734

Merged
merged 1 commit into from
Mar 7, 2017
Merged

Fix nil pointer panic in ParseCSRPEM #734

merged 1 commit into from
Mar 7, 2017

Conversation

cyli
Copy link
Contributor

@cyli cyli commented Mar 7, 2017

Currently ParseCSRPEM will panic if the CSR bytes to be parsed cannot be decoded as a valid PEM block. This adds a check to ensure that the block is valid before passing the DER bytes to x509.ParseCertificateRequest.

block, _ := pem.Decode([]byte(csrPEM))
der := block.Bytes
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

more elegant way is that check block and throw error immediately, instead of relying on CSR parsing to catch the empty input.

…be parsed

as a PEM block.

Signed-off-by: cyli <cyli@twistedmatrix.com>
@lziest lziest merged commit 5bbfc25 into cloudflare:master Mar 7, 2017
@lziest
Copy link
Contributor

lziest commented Mar 7, 2017

won't wait for the snail-speed OSX CI env

@cyli
Copy link
Contributor Author

cyli commented Mar 7, 2017

Thanks!

@cyli cyli deleted the fix-parsecsrpem branch March 7, 2017 23:19
@lziest
Copy link
Contributor

lziest commented Mar 7, 2017

Thank you!

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 this pull request may close these issues.

2 participants