2

I'm getting this error after upgrading from php5.6 to php8.2 on windows. Looks like the new openssl dll does not support splitting of my apple push notification certificate pk12 file into separate cert and key array. Any ideas how to get it to do that ? There is another similar question on stackoverflow but it only discusses ubuntu, not windows. I tried to ask a question to the contributors of the ubuntu related article but i had insufficient permissions.

$p12_filename = "..\\path\\to\\pass.com.testpass.p12";
$p12data = file_get_contents($p12_filename);
$p12Password = 'MyPassword';
$rp12 = array();
// following function works in php5.6 but fails in php8.2
$rc = openssl_pkcs12_read($p12data, $rp12, $p12Password);
$cert_data = $rp12['cert'];
$cert_key = $rp12['pkey'];
6
  • 2
    Might be related? github.com/php/php-src/issues/9890 Commented Jan 2, 2023 at 2:39
  • @Maarten Bodewes - code sample now added although google can't seem to find the other stackoverflow question anymore. Commented Jan 2, 2023 at 10:19
  • @Jacob Mulquin - thanks for the link and it looks like the best workaround. However i am not keen on adding further steps to the server setup process so will investigate the previous version of PHP 8.1.13. Commented Jan 2, 2023 at 10:21
  • 2
    @Jacob Mulquin - have replaced PHP8.2 with PHP8.1.13 and the certificate extraction now works as intended. however it still generates a warning which would be good to resolve => error:0607A082:digital envelope routines:EVP_CIPHER_CTX_set_key_length:invalid key length. Commented Jan 2, 2023 at 10:44
  • Good to hear you got it working in some capacity. I'm not too experienced with this kind of stuff so unable to help you further. Commented Jan 2, 2023 at 10:47

2 Answers 2

2

So according to the link above supplied by Jacob Mulquin , the openssl component supplied in PHP8.2 has a legacy function removed which prevents it from parsing certain types of certificate that were previously supported. As i don't need the latest language enhancements of PHP8.2, the quickest solution for me ( on windows ) was to replace PHP8.2 with the next most recent release, PHP8.1.13.

Sign up to request clarification or add additional context in comments.

Comments

0

you can use openssl command for pre extrack and use certificate in php.

openssl pkcs12 -in key.p12 -legacy -out Behsazan.crt -node

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.