Using pem with password for apns - php

Sorry if this is basic but can't find an exact solution anywhere.

there is php code for APNS that is configured and working fine. a production pem file has now been provided which is password protected.

kindly instruct where / how to pass this password parameter to php. the push code looks like this:

 $apnsHost = 'gateway.sandbox.push.apple.com';
$apnsPort = 2195;
$apnsCert = GetPemUrl();

$streamContext = stream_context_create();
stream_context_set_option($streamContext, 'ssl', 'local_cert', $apnsCert);

$apns = stream_socket_client('ssl://' . $apnsHost . ':' . $apnsPort, $error, $errorString, 10, STREAM_CLIENT_CONNECT, $streamContext);

$sent = False;

if ($apns) {
    $apm = fwrite($apns, $apnsMessage);

    if ($apm)
    {
        $sent = true;
    }
    else
    {
        $sent = FALSE;
    }

    //socket_close($apns);
    fclose($apns);
}

      

+3


source to share


1 answer


accidentally found a solution and posted it in case anyone needs it. add another option for streaming context:

$streamContext = stream_context_create();
stream_context_set_option($streamContext, 'ssl', 'local_cert', $apnsCert);
stream_context_set_option($streamContext, 'ssl', 'passphrase', "pem file passphrase"); // simlply add this

      



following link for full post:

http://learn-php-by-example.blogspot.com/2013/01/working-with-apple-push-notification.html

+2


source







All Articles