Answer the question
In order to leave comments, you need to log in
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 'не считалось!';
Answer the question
In order to leave comments, you need to log in
And it didn't count.Turn on the display of errors, and it will be clear why.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question