nov / itunes-receipt

Handle iTunes In App Purchase Receipt Verification
MIT License
94 stars 65 forks source link

RestClient::SSLCertificateNotVerified Error #22

Closed kaomte closed 2 months ago

kaomte commented 6 years ago

I've been getting these errors in production. I've fixed the issue on a custom branch of mine by swapping out RestClient for Faraday.

I, [2018-03-01T15:53:16.455400 #19005] INFO -- : Celluloid 0.17.2 is running in BACKPORTED mode. [ http://git.io/vJf3J ] Loading development environment (Rails 4.2.5) irb(main):001:0> require 'itunes' => false irb(main):002:0> Itunes::Receipt.verify!({}) RestClient::SSLCertificateNotVerified: SSL_connect returned=1 errno=0 state=error: certificate verify failed: from /Users/kaom/.rbenv/versions/2.1.10/lib/ruby/gems/2.1.0/gems/rest-client-1.8.0/lib/restclient/request.rb:445:inrescue in transmit'`

guih commented 6 years ago

I'm getting the same here.

guih commented 6 years ago

@kaomte It's not security advised but if you're desperate about it you can patch this gem to ignore SSL verifications by adding a file like this in your project:

module Itunes
  class Receipt
    def self.post_to_endpoint(request_data, endpoint = Itunes.endpoint)
      response = RestClient::Request.execute(
        method: :post,
        url: endpoint,
        payload: request_data.to_json,
        verify_ssl: OpenSSL::SSL::VERIFY_NONE
      )
      JSON.parse(response).with_indifferent_access
    end
  end
end

If you use Rails it would be ~lib/itunes/receipt.rb~ within some initializer. [EDITED]

But we should wait for a better either anyway.

guih commented 6 years ago

Adding more information, it looks like the actual issue is https://github.com/nov/restclient_with_cert/issues/1