expo-community / expo-server-sdk-ruby

A Ruby library for sending push notifications with Expo's notification service
MIT License
95 stars 53 forks source link

Posting notifications gives you ssl peer check failed error #42

Open Aryk opened 2 years ago

Aryk commented 2 years ago

This started happening out of the blue and my notifications stopped working on production (Im using AWS).

Adding ssl_verifypeer: false fixed the issue (or '-k' option in curl).

Not sure if you guys experienced this too, but here is my solution.

 class TyphoeusNoSSLCheck
      # @aryk - The push notifications just stopped out of nowhere because they expo servers changed something with their ssl
      # certificates (I think) which caused the notifications to not get sent. After some debugging I used the "-k" option on curl
      # or ssl_verifypeer: false option in this library. This is only required when the calls are made from AWS.
      def self.post(*args)
        options = args.last.is_a?(Hash) ? args.pop : {}
        Typhoeus.post(*args, **options, ssl_verifypeer: false)
      end
    end
asanger commented 2 years ago

Sorry, but how is this used in your workflow? I'm doing something like

client = Exponent::Push::Client.new
...
...
client.send_messages messages

Is your code supposed to monkeypatch Typhoeus?

Aryk commented 2 years ago

No monkey patching required:

     def client
        @client ||= Exponent::Push::Client.new(http_client: TyphoeusNoSSLCheck)
      end
asanger commented 2 years ago

ah, lovely. Thank you!

Aryk commented 2 years ago

@asanger FYI I made a fork that allows to easily add the nossl check without needing to pass in a class:

https://github.com/expo-community/expo-server-sdk-ruby/issues/43