Skip to content

Commit

Permalink
Extract SSL verify none warning to its own method (#837)
Browse files Browse the repository at this point in the history
A tiny refactor where we extract the warning you get when setting SSL
verify mode to `VERIFY_NONE` into its own method. No real impetus for
this except that it extracts very nicely, and that gets us to a smaller
`create_connection` method.
  • Loading branch information
brandur authored and brandur-stripe committed Aug 20, 2019
1 parent 5b975f6 commit 82b5e51
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions lib/stripe/connection_manager.rb
Original file line number Diff line number Diff line change
Expand Up @@ -109,14 +109,7 @@ def execute_request(method, uri, body: nil, headers: nil, query: nil)
connection.cert_store = Stripe.ca_store
else
connection.verify_mode = OpenSSL::SSL::VERIFY_NONE

unless @verify_ssl_warned
@verify_ssl_warned = true
warn("WARNING: Running without SSL cert verification. " \
"You should never do this in production. " \
"Execute `Stripe.verify_ssl_certs = true` to enable " \
"verification.")
end
warn_ssl_verify_none
end

connection
Expand All @@ -134,5 +127,15 @@ def execute_request(method, uri, body: nil, headers: nil, query: nil)
[u.host, u.port, u.user, u.password]
end
end

private def warn_ssl_verify_none
return if @verify_ssl_warned

@verify_ssl_warned = true
warn("WARNING: Running without SSL cert verification. " \
"You should never do this in production. " \
"Execute `Stripe.verify_ssl_certs = true` to enable " \
"verification.")
end
end
end

0 comments on commit 82b5e51

Please sign in to comment.