尝试连接Apple推送通知服务时,为什么会出现OpenSSL错误?

时间:2015-11-02 09:27:18

标签: ruby openssl apple-push-notifications

也许还有其他问题可以解决,但我似乎无法解决我的问题。

我正在尝试使用Apple推送通知服务作为提供程序,使用ruby 2.2.3。

我尝试了一系列我发现的宝石,但它们都有同样的问题。我尝试过的宝石是:

  1. grocer
  2. apns
  3. houston
  4. 他们都提出了同样的例外:

    OpenSSL::SSL::SSLError: SSL_connect SYSCALL returned=5 errno=0 state=SSLv3 read server session ticket A
    

    这些宝石正在使用OpenSSL创建到APNS端点的SSL连接。但他们没有做到这一点。

    请注意,我正在使用Mac OS X Yosemite机器。

    任何帮助?

    编辑有关我如何使用grocer的更多信息:

    pusher = Grocer.pusher(
      certificate: "/Users/panayotismatsinopoulos/Documents/ProgrammingSwift/certificate.pem",
      passphrase:  "the passphrase for loading certificate",
      gateway:     "gateway.sandbox.push.apple.com",
      port:        2195,
      retries:     3
    )
    
    notification = Grocer::Notification.new(
      device_token: "....the device token here...",
      alert: "Hello There!",
      badge: 42)
    
    pusher.push(notification)
    

    我得到的例外是:

    OpenSSL::SSL::SSLError: SSL_connect SYSCALL returned=5 errno=0 state=SSLv3 read server session ticket A
        from /Users/panayotismatsinopoulos/.rvm/gems/ruby-2.2.3@my_project/gems/grocer-0.6.1/lib/grocer/ssl_connection.rb:43:in `connect'
        from /Users/panayotismatsinopoulos/.rvm/gems/ruby-2.2.3@my_project/gems/grocer-0.6.1/lib/grocer/ssl_connection.rb:43:in `connect'
        from /Users/panayotismatsinopoulos/.rvm/gems/ruby-2.2.3@my_project/gems/grocer-0.6.1/lib/grocer/connection.rb:29:in `connect'
        from /Users/panayotismatsinopoulos/.rvm/gems/ruby-2.2.3@my_project/gems/grocer-0.6.1/lib/grocer/connection.rb:55:in `with_connection'
        from /Users/panayotismatsinopoulos/.rvm/gems/ruby-2.2.3@my_project/gems/grocer-0.6.1/lib/grocer/connection.rb:23:in `write'
        from /Users/panayotismatsinopoulos/.rvm/gems/ruby-2.2.3@my_project/gems/grocer-0.6.1/lib/grocer/pusher.rb:8:in `push'
        from (irb):29
        from /Users/panayotismatsinopoulos/.rvm/gems/ruby-2.2.3@my_project/gems/railties-4.2.4/lib/rails/commands/console.rb:110:in `start'
        from /Users/panayotismatsinopoulos/.rvm/gems/ruby-2.2.3@my_project/gems/railties-4.2.4/lib/rails/commands/console.rb:9:in `start'
        from /Users/panayotismatsinopoulos/.rvm/gems/ruby-2.2.3@my_project/gems/railties-4.2.4/lib/rails/commands/commands_tasks.rb:68:in `console'
        from /Users/panayotismatsinopoulos/.rvm/gems/ruby-2.2.3@my_project/gems/railties-4.2.4/lib/rails/commands/commands_tasks.rb:39:in `run_command!'
        from /Users/panayotismatsinopoulos/.rvm/gems/ruby-2.2.3@my_project/gems/railties-4.2.4/lib/rails/commands.rb:17:in `<top (required)>'
        from bin/rails:4:in `require'
        from bin/rails:4:in `<main>'
    

1 个答案:

答案 0 :(得分:4)

最后,我意识到我使用了错误的.pem文件。这不是我试图将通知推送到移动应用程序的具体内容。 这是与签名证书相对应的.pem文件,用于签署我的代码。

只要我使用了正确的.pem文件,一切都顺利进行。