E
E
EVOSandru62015-04-08 07:31:29
PHP
EVOSandru6, 2015-04-08 07:31:29

How to correctly read rsa/pem files in php?

Good afternoon,
following the instructions given php.net/manual/ru/function.openssl-pkcs12-read.php ,
created egov / exapmle.pem file with the following content:
----- the BEGIN CERTIFICATE -----
MIIBfTCCASoCCQDGS0qiKF8OKTAKBgYqhQMCAgMFADBFMQswCQYDVQQGEwJSVTET
MBEGA1UECAwKU29tZS1TdGF0ZTEhMB8GA1UECgwYSW50ZXJuZXQgV2lkZ2l0cyBQ
dHkgTHRkMB4XDTEzMDEzMDEyMzkyN1oXDTEzMDMwMTEyMzkyN1owRTELMAkGA1UE
BhMCUlUxEzARBgNVBAgMClNvbWUtU3RhdGUxITAfBgNVBAoMGEludGVybmV0IFdp
ZGdpdHMgUHR5IEx0ZDBjMBwGBiqFAwICEzASBgcqhQMCAiQABgcqhQMCAh4BA0MA
BEDHgQAkxQJ95kibeD8kuRGv17zTWWIkf2JhnRuyZ7OzTJQyeG3KaxZ1je4lVq e +
6 + i38lUu33cVESIU9L6Mc2SyMAoGBiqFAwICAwUAA0EARj1I65tsiChYFM0thKlI
+ YIH AZQ / OgUe7 + QzVxVoQg9W8OT845us4GDo3WnQArmJIPa6PtSJxfQqz9NAXROK
sA ==
----- the END CERTIFICATE -----
----- the BEGIN The ENCRYPTED the PRIVATE the KEY -----
MIGUMEAGCSqGSIb3DQEFDTAzMBsGCSqGSIb3DQEFDDAOBAh4XqCnZOBdCQICCAAw
FAYIKoZIhvcNAwcECGhYNP5cyMy1BFAKl4hAt8HUtmR8DjatIygwgSyD34qxAdJv
5S6r / 3ICRZbDt7ALdO1fCvPM8rizSBuRX / Zp8t + 470DmafgpK31vpB5Jd6GbwSNj
Kz5bupBSKQ ==
- ---END ENCRYPTED PRIVATE KEY----- I

wrote the following construction in the php file:

$file_name  = 'egov/example.pem';
$handle = file_get_contents($file_name);
if(openssl_pkcs12_read($handle, $certs, "***" )){
    print_r($certs);
}
else echo 'не считалось!';

And it didn't count.
In php.ini on Denwer extension=php_openssl.dll is uncommented.
What could be the problem?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
O
OnYourLips, 2015-04-08
@OnYourLips

And it didn't count.
Turn on the display of errors, and it will be clear why.
And update PHP, Denwer has a very old version.

E
EVOSandru6, 2015-04-08
@EVOSandru6

Updated to PHP/5.5.9 but didn't solve the problem

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question