p.m*_*los 5 ruby openssl apple-push-notifications
也许还有其他问题可以解决,但是我似乎无法解决我的问题。
我正在尝试使用ruby 2.2.3将Apple Push Notification Service用作提供程序。
我尝试了一系列发现的宝石,它们都有相同的问题。我尝试过的宝石是:
它们都引发相同的异常:
OpenSSL::SSL::SSLError: SSL_connect SYSCALL returned=5 errno=0 state=SSLv3 read server session ticket A
Run Code Online (Sandbox Code Playgroud)
这些gem使用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)
Run Code Online (Sandbox Code Playgroud)
我得到的例外是:
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>'
Run Code Online (Sandbox Code Playgroud)
最后,我意识到我使用了错误的.pem
文件。这不是我试图推送通知的特定移动应用程序。这是.pem
与签名证书对应的文件来签署我的代码。
一旦我使用了正确的.pem
文件,一切就顺利了。