为什么在尝试连接到 Apple 推送通知服务时出现 OpenSSL 错误?
Why do I get an OpenSSL error when trying to connect to Apple Push Notification Service?
也许还有其他问题可以回答,但我似乎无法解决我的问题。
我正在尝试使用 Apple 推送通知服务作为提供者,使用 ruby 2.2.3。
我尝试了一系列我发现的 gem,它们都有同样的问题。我尝试过的宝石是:
它们都引发了相同的异常:
OpenSSL::SSL::SSLError: SSL_connect SYSCALL returned=5 errno=0 state=SSLv3 read server session ticket A
这些 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)
我得到的异常是:
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>'
最后,我意识到我使用了错误的 .pem
文件。这不是我试图将通知推送到的特定于移动应用程序的应用程序。
它是与签名证书对应的 .pem
文件来签署我的代码。
只要我使用了正确的 .pem
文件,一切就很顺利了。
也许还有其他问题可以回答,但我似乎无法解决我的问题。
我正在尝试使用 Apple 推送通知服务作为提供者,使用 ruby 2.2.3。
我尝试了一系列我发现的 gem,它们都有同样的问题。我尝试过的宝石是:
它们都引发了相同的异常:
OpenSSL::SSL::SSLError: SSL_connect SYSCALL returned=5 errno=0 state=SSLv3 read server session ticket A
这些 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)
我得到的异常是:
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>'
最后,我意识到我使用了错误的 .pem
文件。这不是我试图将通知推送到的特定于移动应用程序的应用程序。
它是与签名证书对应的 .pem
文件来签署我的代码。
只要我使用了正确的 .pem
文件,一切就很顺利了。