cloudflare / cfssl

CFSSL: Cloudflare's PKI and TLS toolkit
https://cfssl.org/
BSD 2-Clause "Simplified" License
8.57k stars 1.09k forks source link

Failing when file has multiple PEM blocks #969

Open prateeknischal opened 5 years ago

prateeknischal commented 5 years ago

For the command cfssl certinfo -cert <file>, if the file has multiple PEM blocks, it fails with the error

{
  "code": 1003,
  "message": "the PEM file should contain only one object"
}

If we are to go with the openssl behaviour, it should ignore the other PEM blocks and process only the first valid Certificate PEM block it encounters. I can see a snippet that deliberately fails when the file or stream has multiple valid PEM blocks instead of ignoring. https://github.com/cloudflare/cfssl/blob/e04a6ddc69119c6ded64e0f61f76150066040105/helpers/helpers.go#L286-L300 Because, if i want to parse a pem bundle that has all the certificates including issuers and intermediates, i would want to see the leaf, without trying to manually copy it and paste to the stdout.

Please let me know if this sounds like a valid enhancement and I'd be happy to send a pull request.

prateeknischal commented 5 years ago

Fix available at https://github.com/cloudflare/cfssl/pull/970

brandonmcclure commented 3 years ago

I ran into this while setting up cfsll and this issue helped me workaround the error. I would love to see the maintainers of this project comment on this issue/PR.

AndrewSav commented 1 month ago

Interested in a fix