Skip to content

Commit 10bbe67

Browse files
committed
s/VERIFY_NONE/VERIFY_PEER/g as default
1 parent 214d0cd commit 10bbe67

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

lib/rack/reverse_proxy.rb

Lines changed: 10 additions & 2 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
@paths = {}
9-
@opts = {:preserve_host => false}
9+
@opts = {:preserve_host => false, :verify_ssl => true}
1010
instance_eval &b if block_given?
1111
end
1212

@@ -25,8 +25,16 @@ def call(env)
2525
headers['HOST'] = uri.host if @opts[:preserve_host]
2626

2727
session = Net::HTTP.new(uri.host, uri.port)
28+
2829
session.use_ssl = (uri.scheme == 'https')
29-
session.verify_mode = OpenSSL::SSL::VERIFY_NONE
30+
31+
if uri.scheme == 'https' && @opts[:verify_ssl]
32+
session.verify_mode = OpenSSL::SSL::VERIFY_PEER
33+
else
34+
# DO NOT DO THIS IN PRODUCTION !!!
35+
session.verify_mode = OpenSSL::SSL::VERIFY_NONE
36+
end
37+
3038
session.start { |http|
3139
m = rackreq.request_method
3240
case m

0 commit comments

Comments
 (0)