Created
January 21, 2013 13:13
-
-
Save brankoajzele/4585931 to your computer and use it in GitHub Desktop.
Converting .cer to .pem via pure PHP, (no system, backticks, shell_exec, exec, etc.) to get the same result as with "openssl x509 -inform der -in cert.cer -out cert.pem". Note, I am not expert on certificates, etc. This specific certificate conversion simply worked for me.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$certificateCAcer = '/certificate.cer'; | |
$certificateCAcerContent = file_get_contents($certificateCAcer); | |
/* Convert .cer to .pem, cURL uses .pem */ | |
$certificateCApemContent = '-----BEGIN CERTIFICATE-----'.PHP_EOL | |
.chunk_split(base64_encode($certificateCAcerContent), 64, PHP_EOL) | |
.'-----END CERTIFICATE-----'.PHP_EOL; | |
$certificateCApem = $certificateCAcer.'.pem'; | |
file_put_contents($certificateCApem, $certificateCApemContent); |
You saved my life,
Thank you, sir...
Muchas gracias por el aporte. Me ha servido mucho :)
Thank you for your sharing
thank you for sharing,it's very useful to me
Thanks for your code, is really useful.
Thank you, mate!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thxxx Helped me with Apple Certification