【问题标题】:Error while connecting APNS Server - SSL operation failed with code 1. OpenSSL Error messages: error:14090086:SSL连接 APNS 服务器时出错 - SSL 操作失败,代码为 1。OpenSSL 错误消息:错误:14090086:SSL
【发布时间】:2020-05-12 22:02:18
【问题描述】:

我在连接 APNS 并发送推送通知时遇到以下错误。

错误:

警告:stream_socket_client(): SSL 操作失败,代码为 1。OpenSSL 错误消息:错误:14090086:SSL 例程:ssl3_get_server_certificate:certificate verify failed in /filepath/file.php on line 63

警告:stream_socket_client():无法在第 63 行的 /filepath/file.php 中启用加密

警告:stream_socket_client(): 无法连接到第 63 行 /filepath/file.php 中的 tls://gateway.push.apple.com:2195(未知错误)

我的代码是:

$ctx = stream_context_create();    
tream_context_set_option($ctx, 'ssl', 'local_cert', $pemfile);    
stream_context_set_option($ctx, 'ssl', 'passphrase', $passphrase);    
$fp = stream_socket_client(
            'ssl://gateway.push.apple.com:2195',
            $err,
            $errstr,
            60,
            STREAM_CLIENT_CONNECT | STREAM_CLIENT_PERSISTENT,
            $ctx
        );

似乎 .pem 文件 ($pemfile) 没有通过 SSL 连接。

我使用的是 PHP 版本 7.2.8

【问题讨论】:

  • tream_context_set_option() ???缺少s

标签: php ssl push-notification apple-push-notifications stream-socket-client


【解决方案1】:

最后,我通过替换解决了我的问题

$ctx = stream_context_create();

与:

$ctx = stream_context_create([
            'ssl' => [
                'verify_peer'      => false,
                'verify_peer_name' => false
            ]
        ]);

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-03-02
    • 2022-06-12
    • 1970-01-01
    • 2022-01-11
    • 2017-05-21
    • 2020-05-09
    相关资源
    最近更新 更多