Push notifications server implementation
Asked Answered
M

5

3

I'm trying to make work apns-php (http://code.google.com/p/apns-php/) on my server (Bluehost with dedicated IP and port 2195 open for tcp and udp outgoing).

I'm getting this error:

Fatal error: Uncaught exception 'ApnsPHP_Exception' with message 'Unable to connect to 'ssl://gateway.sandbox.push.apple.com:2195': (0)' in /home2/xxxxx/public_html/xxxxx/pns/ApnsPHP/Abstract.php:352 Stack trace: #0 /home2/xxxxx/public_html/xxxxx/pns/ApnsPHP/Abstract.php(295): ApnsPHP_Abstract->_connect() #1 /home2/xxxxx/public_html/xxxxx/pns/sample_push.php(41): ApnsPHP_Abstract->connect() #2 {main} thrown in /home2/xxxxx/public_html/xxxxx/pns/ApnsPHP/Abstract.php on line 352

I have contact Bluehost support and they told me this:

Thanks for contacting us. If seems as though the server ssl://gateway.sandbox.push.apple.com:2195* is refusing to accept the connection made from your account. Is there a way you can whitelist your dedicated ip or accept incoming connections on their end?

Someone can help me to solve this out? Any ideas? Thanks!

Mesdemoiselles answered 13/3, 2011 at 20:42 Comment(0)
M
11

I have found a solution, I don't know if it's the best, but it works. On Abstract.php (this file is part of the apns-php source) I have commented the line 343. Now it looks like this:

$streamContext = stream_context_create(array('ssl' => array(
//'verify_peer' => isset($this->_sRootCertificationAuthorityFile),
'cafile' => $this->_sRootCertificationAuthorityFile,
'local_cert' => $this->_sProviderCertificateFile
)));

I really don't know what is the point of this line, but know the push notification is working properly. My doubt is if it will work properly too on production server. Someone knows?

Mesdemoiselles answered 13/3, 2011 at 21:56 Comment(3)
I have tested it on my own web server (WAMP on Windows 7) and now it works too.Mesdemoiselles
you might check this out too: groups.google.com/forum/#!topic/apns-php/IdzCrxPze7ACarmelinacarmelita
This means you are disabling verify peer using Entrust Root Certification Authority, double check your root CA most probably you might be using same file for SSL client authentication and the root CAReiss
P
0

you may need to contact apple .. as by what it sounds like is that apple blocked ur application from accessing their gateway .. you would need to contact apple so that you can get your ip address or web app approved

Peradventure answered 13/3, 2011 at 21:15 Comment(0)
P
0

This problem is exactly what i was seeing in local development. I'm assuming you'd want to uncomment that line once it's on the server and the certs are all setup properly.

Pict answered 27/7, 2011 at 15:50 Comment(0)
I
0

In our case we did not do the last part of this tutorial; http://code.google.com/p/apns-php/wiki/CertificateCreation (thinking it was optional)

Which resulted in exactly the same errors as you had.

After we did that, everything worked as expected.

Inoperable answered 20/8, 2012 at 12:57 Comment(0)
R
0

I had same issue and what I did wrong was providing same certificate for SSL client authentication and the root CA, below code worked for me

$push = new ApnsPHP_Push(
        ApnsPHP_Abstract::ENVIRONMENT_SANDBOX,
        'ck.pem'
    );

$push->setRootCertificationAuthority('entrust_root_certification_authority.pem');

https://code.google.com/p/apns-php/wiki/CertificateCreation

Reiss answered 11/8, 2014 at 14:3 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.