无法使用php-apn向IOS发送推送通知

Hi I have installed the package php-apn on linux for sending push notifications to IOS and the error I get is:

"unable to use specified private key"

I also initially tried it using stream_socket_client and got a similar error. The path to the key/cert are correct, I have regenerated the keys/certs again with the same outcome

The code is below

        // APNS contex
        $apn = apn_init();
        apn_set_array($apn, array(
              'certificate' => '/var/www/html/scripts/certs/PushChatCert.pem',
              'private_key' => '/var/www/html/scripts/certs/apns_cert.pem',
             // 'private_key_pass' => '',
              'mode' => APN_PRODUCTION
          ));
        //APN_SANDBOX
        // Notification Payload context
        $payload = apn_payload_init();
        apn_payload_set_array($payload, array(
              'body' => 'push ',
              'sound' => 'default',
              'badge' => 1,
              'tokens' => array ('XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
              )
        ));
        apn_payload_add_custom_property($payload, 'test', 56);

        $error = NULL;
        $errcode = 0;

        // Opening Apple Push Notification Service connection...
        if(apn_connect($apn, $error, $errcode)) {
            // and if ok, try send push notification....
            if(!apn_send($apn, $payload, $error, $errcode)) {
                echo 'Could not sent push notification: ' . $error;
            }
        } else {
            echo 'Could not connected to Apple Push Notification Service: ' . $error;
        }

        apn_close($apn);
        apn_payload_free($payload);
        apn_free($apn);