spiffe/go-spiffe

PEM parsing fails for bundles with trailing newline for v2.0.0-beta.6

mweissbacher opened this issue · 3 comments

Hi,

I noticed behavior that was surprising to me when testing on tag v2.0.0-beta.6. When parsing a PEM file via x509bundle.Parse I receive the following error if there is a trailing newline in the file.

Error:      	Received unexpected error:
       	            	x509bundle: cannot parse certificate: no PEM data found while decoding block
       	            		github.com/spiffe/go-spiffe/v2/bundle/x509bundle.Parse:68
       	            		github.com/spiffe/go-spiffe/v2/bundle/x509bundle_test.TestParse.func1:131
       	            		testing.tRunner:1123
       	Test:       	TestParse/staging_root

I receive no error when removing the newline. My expectation would be to parse without an error, or is this expected behavior?

To reproduce add a trailing newline to go-spiffe/v2/bundle/x509bundle/testdata/certs.pem and run tests.

That is not expected and certainly a bug! Thanks for catching that.

I'm currently working on some other changes to the library. I'll go ahead and fix this while I'm in there and push a new version. Should happen this week.

Thank you @azdagron !