openssl x509 certificate problems
Posted 21 November 2007 - 04:13 AM
I need to extract it's public key and use the public key to encrypt a value...
I get these errors:
Warning: openssl_x509_read() [function.openssl-x509-read]: supplied parameter cannot be coerced into an X509 certificate! in /public_html/test/cert.php on line 26
Warning: openssl_x509_free() expects parameter 1 to be resource, string given in /public_html/test/cert.php on line 34
$fp = fopen("/home/x.cer", "r");
$cert = fread($fp, 8192);
$data = openssl_x509_parse($cert);
openssl_x509_free( $cert );
Any ideas what is wrong...
Starting to get frustrated...
Thanks in advance
Posted 21 November 2007 - 11:26 AM
Posted 16 June 2009 - 07:41 PM
1. Generate a *.PEM certificate (Privacy Enhanced Mail) via Openssl command:
openssl pkcs12 -in YOUR_pkcs12_certificate.pfx -out YOUR_NEW_CERTIFICATE.pem
2.The source code of PHP must be compiled with openssl option:
$cert = file_get_contents("OUR_NEW_CERTIFICATE.pem");
$ssl = openssl_x509_parse($cert);
Posted 31 October 2009 - 08:31 PM
In case you don't knoew what it means - it's 2 hidden characters at the beginning of a file that indicates it is encoded with UTF-8.
Notepad and other applications put it there by default.
To remove it:
If the file has only english characters (like certificates should have) - Open the file with notepad and click file>save as.
In the 'encoding' field select 'ANSI', and save the file.
Another option is to use HEX editor (I use xvi32 - free and good), and delete the first 2 characters.
I hope this helps someone...
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users