edamov / pushok

PHP client for Apple Push Notification Service (APNs) - Send push notifications to iOS using the new APNs HTTP/2 protocol with token-based (JWT with p8 private key)
MIT License
368 stars 119 forks source link

configurable curl options (avoid http_code 0) #109

Closed tobiasbambullis closed 1 year ago

tobiasbambullis commented 3 years ago

hey,

great plugin! One small thing we had to change. In our productive system we got a http_code = 0 when calling $client->push().

So we changed Client.php to this:

`private function prepareHandle(Notification $notification) { $request = new Request($notification, $this->isProductionEnv); $ch = curl_init();

$this->authProvider->authenticateClient($request);

curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); 
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt_array($ch, $request->getOptions());
curl_setopt($ch, CURLOPT_HTTPHEADER, $request->getDecoratedHeaders());

// store device token to identify response
curl_setopt($ch, CURLOPT_PRIVATE, $notification->getDeviceToken());

return $ch;

}`

It would be a better solution if "Client" has a method like "setOptions" where you can set all curl options to do it!

pnlarsson commented 3 years ago
# curl https://api.push.apple.com
curl: (60) SSL certificate problem: unable to get local issuer certificate
More details here: https://curl.haxx.se/docs/sslcerts.html

https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=962596

Debian removed GeoTrust cert that Apple CA was signed with (kind of).

This solved it for me:

wget --no-check-certificate -c https://www.geotrust.com/resources/root_certificates/certificates/GeoTrust_Global_CA.pem   \
    && mkdir /usr/local/share/ca-certificates/extra                                                                       \
    && mv GeoTrust_Global_CA.pem /usr/local/share/ca-certificates/extra/GeoTrust_Global_CA.crt                            \
    && update-ca-certificates