I had the same problem as sunnycomes and his comment was correct. I was lacking a ‘-‘ at the very end of the last line of the file. Before I had:
-----END CERTIFICATE----
and changing it to:
-----END CERTIFICATE-----
fixed it. I’ve learnt that I have to be careful when copying certificates text from a terminal.