In my case it was about line endings. I have nginx on Windows and the certificate had (\r) line endings. I changed them to (\r\n) line endings with a text editor and it worked.