stream_socket_client在我的服务器上失败,无法进一步了解该错误

Stu*_* mc 5 php ssl client-certificates apple-push-notifications stream-socket-client

这段代码:(https://github.com/stuffmc/Safari-Push-Notifications/blob/master/index.php#L195

stream_socket_client('ssl://gateway.push.apple.com:2195', $error, $errorString, 
                      60, STREAM_CLIENT_CONNECT, $streamContext);
Run Code Online (Sandbox Code Playgroud)

返回false,但没有错误。这意味着当我发送到/ v1 / push时,它对于每个设备/令牌都失败:( PHP文档说:

如果errno中返回的值为0,并且函数返回FALSE,则表明该错误发生在connect()调用之前。这很可能是由于初始化套接字时出现问题。

我的代码可以完美地在网站上运行(dev / beta / staging),而现在我正尝试进入生产环境,但现在还没有。

我应该注意的是

$ openssl s_client -connect gateway.push.apple.com:2195 -cert MyC.pem -key myK.pem
Run Code Online (Sandbox Code Playgroud)

完美的作品。我有一个提示,我可以在其中键入字符,键入Enter时,它会退出-与我的dev测试相同。

我也没有任何东西发送给/v1/log(如在https://devforums.apple.com/thread/203825提到的),所以我对问题在哪里一无所知:(

Stu*_* mc 4

我通过以下方式生成 .pem 解决了我的问题:

openssl pkcs12 -in key-chain-export.p12 -out apple_push_cert_production.pem -nodes -clcerts
Run Code Online (Sandbox Code Playgroud)

我仍然很想知道如何获得“提示”(来自 PHP 或 openssl)它是证书。

:虽然它解决了服务器端的问题,但我随后在客户端遇到了问题。那好吧.....

我还应该提到我修复了服务器上的代码,以便/v1/log从 Apple 获得一些东西。

请参阅https://github.com/surrealroad/Safari-Push-Notifications/commit/0ae8a3ad3327a957c332090ea1bfcb146a40c5f3