Skip to content
This repository has been archived by the owner on Jan 15, 2021. It is now read-only.

Override paypal-sdk-core ca_file setting #8

Merged
merged 1 commit into from
Aug 7, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 16 additions & 0 deletions lib/spree_paypal_express/engine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,21 @@ def self.activate
initializer "spree.paypal_express.payment_methods", :after => "spree.register.payment_methods" do |app|
app.config.spree.payment_methods << Spree::Gateway::PayPalExpress
end

# Fixes the issue about some PayPal requests failing with
# OpenSSL::SSL::SSLError (SSL_connect returned=1 errno=0 state=error: certificate verify failed)
module CAFileHack
# This overrides paypal-sdk-core default so we don't pass the cert the gem provides to the
# NET::HTTP instance. This way we rely on the default behavior of validating the server's cert
# against the CA certs of the OS (we assume), which tend to be up to date.
#
# See https://github.com/openfoodfoundation/openfoodnetwork/issues/5855 for details.
def default_ca_file
nil
end
end

require 'paypal-sdk-merchant'
::PayPal::SDK::Core::Util::HTTPHelper.prepend(CAFileHack)
end
end