You get much higher quality answers if you enable us to reproduce the problem (
sscce,
mcve). As the question stands now, only guessing is possible. Please edit it to add the relevant details.
files not having the correct text encoding
PEM files in text form are ASCII, that can't be the problem.
just fine using "openssl
The Perl code might not use the same library as the command-line tool, please verify.
› openssl version
› perl -mNet::SSLeay -E "say for Net::SSLeay->VERSION, sprintf q(%X),
+Net::SSLeay::SSLeay"
If the certificate is in actual use,
https://github.com/noxxi/p5-ssl-tools can be helpful.
What is the opinion of gnutls about the file?
› certtool -i < somefile.pem