Some vendors require you to call their API via TLS 1.2 and I don't see that much documentation on how to do this.
- Directly calling Class method.
# Notice the `ssl_version` option, to specify ssl version of the HTTP request
response = HTTParty.get('http://api.stackexchange.com/2.2/questions?site=stackoverflow', ssl_version: :TLSv1_2)
- Wrap HTTParty in your own class.
class StackExchange
include HTTParty
base_uri 'api.stackexchange.com'
# HTTParty would inherit this option
ssl_version :TLSv1_2
def initialize(service, page)
@options = { query: { site: service, page: page } }
end
def questions
self.class.get("/2.2/questions", @options)
end
def users
self.class.get("/2.2/users", @options)
end
end
stack_exchange = StackExchange.new("stackoverflow", 1)
puts stack_exchange.questions
puts stack_exchange.users
Paypal made a dedicated endpoint mainly for this purpose, since they're one of the vendors who requires such ssl version. Reference: https://www.paypal.com/au/webapps/mpp/tls-http-upgrade
Confirm if TLS 1.2 is used properly and received by the server.
curl https://tlstest.paypal.com
Expected Output:
PayPal_Connection_OK
You could also do a pry on your staging / production server and executing HTTParty.get
directly.
If you encounter an error, you must upgrade the OPENSSL library on your machine.