Raptor
Raptor

Reputation: 54258

openssl_x509_export_to_file : cannot get cert from parameter 1

I have an Apple Push Notification Development Push SSL Certificate generated by iOS Dev Center, by a certificate signing request .

I would like to use a PHP to convert certificate format. In Terminal / shell, I can execute this command to convert the certificate format :

openssl x509 -in aps_developer_identity.cer -inform der -out push_cert.pem

In PHP, I have:

$result = openssl_x509_export_to_file('/path/to/aps_developer_identity.cer', '/path/to/push_cert.pem');

However, PHP issues a warning:

openssl_x509_export_to_file() : cannot get cert from parameter 1

In PHP documentation, it said that the 1st parameter can be file path to the certificate file.

Given that:

What could be the problem?

Upvotes: 0

Views: 3199

Answers (1)

neubert
neubert

Reputation: 16802

From phpseclib, a pure PHP X.509 implementation:

"-----BEGIN CERTIFICATE-----\r\n" .
chunk_split(base64_encode($cert), 64) .
'-----END CERTIFICATE-----'

Upvotes: 1

Related Questions