Skip to content

Commit 2ce83d6

Browse files
committed
Merge branch 'verify-ssl' of https://github.com/librato/rack-reverse-proxy into librato-verify-ssl
Conflicts: lib/rack/reverse_proxy.rb
2 parents 8cd6be4 + 10bbe67 commit 2ce83d6

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

lib/rack/reverse_proxy.rb

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ class ReverseProxy
66
def initialize(app = nil, &b)
77
@app = app || lambda { [404, [], []] }
88
@matchers = []
9-
@global_options = {:preserve_host => false,:matching => :all}
9+
@global_options = {:preserve_host => false, :matching => :all, :verify_ssl => true}
1010
instance_eval &b if block_given?
1111
end
1212

@@ -26,9 +26,15 @@ def call(env)
2626
headers['HOST'] = uri.host if all_opts[:preserve_host]
2727

2828
session = Net::HTTP.new(uri.host, uri.port)
29-
session.use_ssl = (uri.scheme == 'https')
30-
session.verify_mode = OpenSSL::SSL::VERIFY_NONE
3129
session.read_timeout=all_opts[:timeout] if all_opts[:timeout]
30+
31+
session.use_ssl = (uri.scheme == 'https')
32+
if uri.scheme == 'https' && all_opts[:verify_ssl]
33+
session.verify_mode = OpenSSL::SSL::VERIFY_PEER
34+
else
35+
# DO NOT DO THIS IN PRODUCTION !!!
36+
session.verify_mode = OpenSSL::SSL::VERIFY_NONE
37+
end
3238
session.start { |http|
3339
m = rackreq.request_method
3440
case m
@@ -54,7 +60,7 @@ def call(env)
5460
[res.code, create_response_headers(res), [body]]
5561
}
5662
end
57-
63+
5864
private
5965

6066
def get_matcher path

0 commit comments

Comments
 (0)