bundler 4.0.23 → 4.1.0.beta1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (188) hide show
  1. checksums.yaml +4 -4
  2. data/{lib/bundler/vendor/connection_pool/LICENSE → MIT.txt} +8 -6
  3. data/bundler.gemspec +23 -6
  4. data/lib/bundler/build_metadata.rb +2 -2
  5. data/lib/bundler/checksum.rb +40 -25
  6. data/lib/bundler/ci_detector.rb +1 -1
  7. data/lib/bundler/cli/add.rb +3 -4
  8. data/lib/bundler/cli/cache.rb +4 -0
  9. data/lib/bundler/cli/clean.rb +5 -0
  10. data/lib/bundler/cli/common.rb +37 -1
  11. data/lib/bundler/cli/config.rb +4 -2
  12. data/lib/bundler/cli/gem.rb +0 -17
  13. data/lib/bundler/cli/install.rb +4 -5
  14. data/lib/bundler/cli/lock.rb +4 -16
  15. data/lib/bundler/cli/outdated.rb +8 -3
  16. data/lib/bundler/cli/platform.rb +1 -15
  17. data/lib/bundler/cli/pristine.rb +2 -1
  18. data/lib/bundler/cli/update.rb +21 -12
  19. data/lib/bundler/cli.rb +19 -28
  20. data/lib/bundler/definition.rb +61 -24
  21. data/lib/bundler/dependency.rb +4 -0
  22. data/lib/bundler/dsl.rb +77 -11
  23. data/lib/bundler/endpoint_specification.rb +51 -14
  24. data/lib/bundler/env.rb +7 -24
  25. data/lib/bundler/errors.rb +34 -5
  26. data/lib/bundler/fetcher/compact_index.rb +14 -5
  27. data/lib/bundler/fetcher/connection_pools.rb +150 -0
  28. data/lib/bundler/fetcher/downloader.rb +33 -24
  29. data/lib/bundler/fetcher.rb +8 -47
  30. data/lib/bundler/injector.rb +3 -3
  31. data/lib/bundler/inline.rb +44 -4
  32. data/lib/bundler/installer/parallel_installer.rb +25 -30
  33. data/lib/bundler/installer.rb +20 -10
  34. data/lib/bundler/lazy_specification.rb +44 -17
  35. data/lib/bundler/lockfile_generator.rb +24 -2
  36. data/lib/bundler/lockfile_parser.rb +43 -5
  37. data/lib/bundler/man/bundle-add.1 +7 -4
  38. data/lib/bundler/man/bundle-add.1.ronn +8 -4
  39. data/lib/bundler/man/bundle-binstubs.1 +1 -1
  40. data/lib/bundler/man/bundle-cache.1 +2 -2
  41. data/lib/bundler/man/bundle-cache.1.ronn +2 -2
  42. data/lib/bundler/man/bundle-check.1 +1 -1
  43. data/lib/bundler/man/bundle-clean.1 +1 -1
  44. data/lib/bundler/man/bundle-config.1 +38 -6
  45. data/lib/bundler/man/bundle-config.1.ronn +143 -10
  46. data/lib/bundler/man/bundle-console.1 +1 -1
  47. data/lib/bundler/man/bundle-doctor.1 +1 -1
  48. data/lib/bundler/man/bundle-env.1 +1 -1
  49. data/lib/bundler/man/bundle-exec.1 +1 -1
  50. data/lib/bundler/man/bundle-fund.1 +1 -1
  51. data/lib/bundler/man/bundle-gem.1 +1 -1
  52. data/lib/bundler/man/bundle-help.1 +1 -1
  53. data/lib/bundler/man/bundle-info.1 +1 -1
  54. data/lib/bundler/man/bundle-init.1 +1 -1
  55. data/lib/bundler/man/bundle-install.1 +2 -2
  56. data/lib/bundler/man/bundle-install.1.ronn +4 -4
  57. data/lib/bundler/man/bundle-issue.1 +1 -1
  58. data/lib/bundler/man/bundle-licenses.1 +1 -1
  59. data/lib/bundler/man/bundle-list.1 +1 -1
  60. data/lib/bundler/man/bundle-lock.1 +4 -4
  61. data/lib/bundler/man/bundle-lock.1.ronn +6 -6
  62. data/lib/bundler/man/bundle-open.1 +1 -1
  63. data/lib/bundler/man/bundle-outdated.1 +2 -2
  64. data/lib/bundler/man/bundle-outdated.1.ronn +1 -1
  65. data/lib/bundler/man/bundle-platform.1 +1 -1
  66. data/lib/bundler/man/bundle-plugin.1 +1 -1
  67. data/lib/bundler/man/bundle-pristine.1 +1 -1
  68. data/lib/bundler/man/bundle-remove.1 +1 -1
  69. data/lib/bundler/man/bundle-show.1 +1 -1
  70. data/lib/bundler/man/bundle-update.1 +5 -5
  71. data/lib/bundler/man/bundle-update.1.ronn +5 -7
  72. data/lib/bundler/man/bundle-version.1 +1 -1
  73. data/lib/bundler/man/bundle.1 +1 -1
  74. data/lib/bundler/man/gemfile.5 +45 -1
  75. data/lib/bundler/man/gemfile.5.ronn +53 -0
  76. data/lib/bundler/match_metadata.rb +20 -0
  77. data/lib/bundler/match_platform.rb +25 -2
  78. data/lib/bundler/match_remote_metadata.rb +21 -6
  79. data/lib/bundler/materialization.rb +2 -1
  80. data/lib/bundler/override.rb +69 -0
  81. data/lib/bundler/plugin/dsl.rb +3 -5
  82. data/lib/bundler/plugin/events.rb +55 -13
  83. data/lib/bundler/plugin/index.rb +87 -11
  84. data/lib/bundler/plugin/installer/path.rb +1 -1
  85. data/lib/bundler/plugin/installer.rb +13 -5
  86. data/lib/bundler/plugin.rb +58 -30
  87. data/lib/bundler/remote_specification.rb +6 -3
  88. data/lib/bundler/resolver/base.rb +2 -1
  89. data/lib/bundler/resolver/incompatibility.rb +1 -1
  90. data/lib/bundler/resolver.rb +73 -23
  91. data/lib/bundler/ruby_version.rb +0 -2
  92. data/lib/bundler/rubygems_ext.rb +71 -1
  93. data/lib/bundler/rubygems_gem_installer.rb +41 -2
  94. data/lib/bundler/rubygems_integration.rb +7 -2
  95. data/lib/bundler/runtime.rb +69 -2
  96. data/lib/bundler/self_manager.rb +9 -15
  97. data/lib/bundler/settings.rb +373 -30
  98. data/lib/bundler/shared_helpers.rb +2 -1
  99. data/lib/bundler/source/git/git_proxy.rb +2 -10
  100. data/lib/bundler/source/git.rb +15 -6
  101. data/lib/bundler/source/path/installer.rb +1 -1
  102. data/lib/bundler/source/rubygems/remote.rb +10 -5
  103. data/lib/bundler/source/rubygems.rb +48 -12
  104. data/lib/bundler/spec_set.rb +16 -4
  105. data/lib/bundler/stub_specification.rb +2 -1
  106. data/lib/bundler/templates/newgem/Gemfile.tt +4 -4
  107. data/lib/bundler/templates/newgem/ext/newgem/Cargo.toml.tt +1 -1
  108. data/lib/bundler/templates/newgem/newgem.gemspec.tt +3 -3
  109. data/lib/bundler/templates/newgem/spec/newgem_spec.rb.tt +1 -1
  110. data/lib/bundler/templates/newgem/test/minitest/test_newgem.rb.tt +1 -1
  111. data/lib/bundler/ui/shell.rb +0 -4
  112. data/lib/bundler/ui/silent.rb +0 -4
  113. data/lib/bundler/vendor/fileutils/lib/fileutils.rb +29 -54
  114. data/lib/bundler/vendored_pub_grub.rb +5 -2
  115. data/lib/bundler/vendored_securerandom.rb +11 -8
  116. data/lib/bundler/vendored_uri.rb +14 -14
  117. data/lib/bundler/version.rb +1 -1
  118. data/lib/bundler/worker.rb +3 -2
  119. data/lib/bundler.rb +4 -2
  120. data/lib/rubygems/compact_index_client/cache.rb +122 -0
  121. data/lib/rubygems/compact_index_client/cache_file.rb +147 -0
  122. data/lib/rubygems/compact_index_client/http_fetcher.rb +88 -0
  123. data/lib/rubygems/compact_index_client/parser.rb +90 -0
  124. data/lib/rubygems/compact_index_client/updater.rb +113 -0
  125. data/lib/rubygems/compact_index_client.rb +111 -0
  126. data/lib/rubygems/cooldown_settings.rb +57 -0
  127. data/lib/rubygems/credential_store/native/linux.rb +97 -0
  128. data/lib/rubygems/credential_store/native/macos.rb +88 -0
  129. data/lib/rubygems/credential_store/native/windows.rb +130 -0
  130. data/lib/rubygems/credential_store.rb +332 -0
  131. data/lib/{bundler → rubygems}/vendor/pub_grub/lib/pub_grub/assignment.rb +1 -1
  132. data/lib/{bundler → rubygems}/vendor/pub_grub/lib/pub_grub/basic_package_source.rb +7 -7
  133. data/lib/{bundler → rubygems}/vendor/pub_grub/lib/pub_grub/failure_writer.rb +1 -1
  134. data/lib/{bundler → rubygems}/vendor/pub_grub/lib/pub_grub/incompatibility.rb +4 -4
  135. data/lib/{bundler → rubygems}/vendor/pub_grub/lib/pub_grub/package.rb +1 -1
  136. data/lib/{bundler → rubygems}/vendor/pub_grub/lib/pub_grub/partial_solution.rb +1 -1
  137. data/lib/{bundler → rubygems}/vendor/pub_grub/lib/pub_grub/rubygems.rb +3 -3
  138. data/lib/{bundler → rubygems}/vendor/pub_grub/lib/pub_grub/solve_failure.rb +1 -1
  139. data/lib/{bundler → rubygems}/vendor/pub_grub/lib/pub_grub/static_package_source.rb +3 -3
  140. data/lib/{bundler → rubygems}/vendor/pub_grub/lib/pub_grub/strategy.rb +2 -2
  141. data/lib/{bundler → rubygems}/vendor/pub_grub/lib/pub_grub/term.rb +1 -1
  142. data/lib/{bundler → rubygems}/vendor/pub_grub/lib/pub_grub/version.rb +1 -1
  143. data/lib/{bundler → rubygems}/vendor/pub_grub/lib/pub_grub/version_constraint.rb +3 -3
  144. data/lib/{bundler → rubygems}/vendor/pub_grub/lib/pub_grub/version_range.rb +1 -1
  145. data/lib/{bundler → rubygems}/vendor/pub_grub/lib/pub_grub/version_solver.rb +2 -2
  146. data/lib/{bundler → rubygems}/vendor/pub_grub/lib/pub_grub/version_union.rb +1 -1
  147. data/lib/rubygems/vendor/pub_grub/lib/pub_grub.rb +57 -0
  148. data/lib/{bundler → rubygems}/vendor/securerandom/lib/securerandom.rb +10 -6
  149. data/lib/{bundler → rubygems}/vendor/uri/lib/uri/common.rb +120 -120
  150. data/lib/{bundler → rubygems}/vendor/uri/lib/uri/file.rb +13 -13
  151. data/lib/{bundler → rubygems}/vendor/uri/lib/uri/ftp.rb +24 -24
  152. data/lib/{bundler → rubygems}/vendor/uri/lib/uri/generic.rb +135 -147
  153. data/lib/{bundler → rubygems}/vendor/uri/lib/uri/http.rb +18 -18
  154. data/lib/{bundler → rubygems}/vendor/uri/lib/uri/https.rb +4 -4
  155. data/lib/{bundler → rubygems}/vendor/uri/lib/uri/ldap.rb +14 -14
  156. data/lib/{bundler → rubygems}/vendor/uri/lib/uri/ldaps.rb +4 -4
  157. data/lib/{bundler → rubygems}/vendor/uri/lib/uri/mailto.rb +21 -21
  158. data/lib/{bundler → rubygems}/vendor/uri/lib/uri/rfc2396_parser.rb +39 -39
  159. data/lib/{bundler → rubygems}/vendor/uri/lib/uri/rfc3986_parser.rb +14 -14
  160. data/lib/{bundler → rubygems}/vendor/uri/lib/uri/version.rb +2 -2
  161. data/lib/{bundler → rubygems}/vendor/uri/lib/uri/ws.rb +12 -12
  162. data/lib/{bundler → rubygems}/vendor/uri/lib/uri/wss.rb +4 -4
  163. data/lib/{bundler → rubygems}/vendor/uri/lib/uri.rb +35 -31
  164. data/lib/rubygems/yaml_serializer.rb +880 -0
  165. metadata +77 -68
  166. data/CHANGELOG.md +0 -5812
  167. data/LICENSE.md +0 -22
  168. data/README.md +0 -58
  169. data/lib/bundler/compact_index_client/cache.rb +0 -107
  170. data/lib/bundler/compact_index_client/cache_file.rb +0 -148
  171. data/lib/bundler/compact_index_client/parser.rb +0 -87
  172. data/lib/bundler/compact_index_client/updater.rb +0 -105
  173. data/lib/bundler/compact_index_client.rb +0 -92
  174. data/lib/bundler/vendor/connection_pool/lib/connection_pool/timed_stack.rb +0 -237
  175. data/lib/bundler/vendor/connection_pool/lib/connection_pool/version.rb +0 -3
  176. data/lib/bundler/vendor/connection_pool/lib/connection_pool/wrapper.rb +0 -56
  177. data/lib/bundler/vendor/connection_pool/lib/connection_pool.rb +0 -233
  178. data/lib/bundler/vendor/net-http-persistent/README.rdoc +0 -82
  179. data/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/connection.rb +0 -41
  180. data/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/pool.rb +0 -65
  181. data/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/timed_stack_multi.rb +0 -89
  182. data/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent.rb +0 -1159
  183. data/lib/bundler/vendor/pub_grub/lib/pub_grub.rb +0 -31
  184. data/lib/bundler/vendored_persistent.rb +0 -11
  185. data/lib/bundler/yaml_serializer.rb +0 -98
  186. /data/lib/{bundler → rubygems}/vendor/pub_grub/LICENSE.txt +0 -0
  187. /data/lib/{bundler → rubygems}/vendor/securerandom/COPYING +0 -0
  188. /data/lib/{bundler → rubygems}/vendor/uri/COPYING +0 -0
@@ -1,1159 +0,0 @@
1
- require_relative '../../../../../vendored_net_http'
2
- require_relative '../../../../../vendored_uri'
3
- require 'cgi/escape'
4
- require 'cgi/util' unless defined?(CGI::EscapeExt)
5
- require_relative '../../../../connection_pool/lib/connection_pool'
6
-
7
- autoload :OpenSSL, 'openssl'
8
-
9
- ##
10
- # Persistent connections for Gem::Net::HTTP
11
- #
12
- # Gem::Net::HTTP::Persistent maintains persistent connections across all the
13
- # servers you wish to talk to. For each host:port you communicate with a
14
- # single persistent connection is created.
15
- #
16
- # Connections will be shared across threads through a connection pool to
17
- # increase reuse of connections.
18
- #
19
- # You can shut down any remaining HTTP connections when done by calling
20
- # #shutdown.
21
- #
22
- # Example:
23
- #
24
- # require 'bundler/vendor/net-http-persistent/lib/net/http/persistent'
25
- #
26
- # uri = Gem::URI 'http://example.com/awesome/web/service'
27
- #
28
- # http = Gem::Net::HTTP::Persistent.new
29
- #
30
- # # perform a GET
31
- # response = http.request uri
32
- #
33
- # # or
34
- #
35
- # get = Gem::Net::HTTP::Get.new uri.request_uri
36
- # response = http.request get
37
- #
38
- # # create a POST
39
- # post_uri = uri + 'create'
40
- # post = Gem::Net::HTTP::Post.new post_uri.path
41
- # post.set_form_data 'some' => 'cool data'
42
- #
43
- # # perform the POST, the Gem::URI is always required
44
- # response http.request post_uri, post
45
- #
46
- # ⚠ Note that for GET, HEAD and other requests that do not have a body,
47
- # it uses Gem::URI#request_uri as default to send query params
48
- #
49
- # == TLS/SSL
50
- #
51
- # TLS connections are automatically created depending upon the scheme of the
52
- # Gem::URI. TLS connections are automatically verified against the default
53
- # certificate store for your computer. You can override this by changing
54
- # verify_mode or by specifying an alternate cert_store.
55
- #
56
- # Here are the TLS settings, see the individual methods for documentation:
57
- #
58
- # #certificate :: This client's certificate
59
- # #ca_file :: The certificate-authorities
60
- # #ca_path :: Directory with certificate-authorities
61
- # #cert_store :: An SSL certificate store
62
- # #ciphers :: List of SSl ciphers allowed
63
- # #extra_chain_cert :: Extra certificates to be added to the certificate chain
64
- # #private_key :: The client's SSL private key
65
- # #reuse_ssl_sessions :: Reuse a previously opened SSL session for a new
66
- # connection
67
- # #ssl_timeout :: Session lifetime
68
- # #ssl_version :: Which specific SSL version to use
69
- # #verify_callback :: For server certificate verification
70
- # #verify_depth :: Depth of certificate verification
71
- # #verify_mode :: How connections should be verified
72
- # #verify_hostname :: Use hostname verification for server certificate
73
- # during the handshake
74
- #
75
- # == Proxies
76
- #
77
- # A proxy can be set through #proxy= or at initialization time by providing a
78
- # second argument to ::new. The proxy may be the Gem::URI of the proxy server or
79
- # <code>:ENV</code> which will consult environment variables.
80
- #
81
- # See #proxy= and #proxy_from_env for details.
82
- #
83
- # == Headers
84
- #
85
- # Headers may be specified for use in every request. #headers are appended to
86
- # any headers on the request. #override_headers replace existing headers on
87
- # the request.
88
- #
89
- # The difference between the two can be seen in setting the User-Agent. Using
90
- # <code>http.headers['User-Agent'] = 'MyUserAgent'</code> will send "Ruby,
91
- # MyUserAgent" while <code>http.override_headers['User-Agent'] =
92
- # 'MyUserAgent'</code> will send "MyUserAgent".
93
- #
94
- # == Tuning
95
- #
96
- # === Segregation
97
- #
98
- # Each Gem::Net::HTTP::Persistent instance has its own pool of connections. There
99
- # is no sharing with other instances (as was true in earlier versions).
100
- #
101
- # === Idle Timeout
102
- #
103
- # If a connection hasn't been used for this number of seconds it will
104
- # automatically be reset upon the next use to avoid attempting to send to a
105
- # closed connection. The default value is 5 seconds. nil means no timeout.
106
- # Set through #idle_timeout.
107
- #
108
- # Reducing this value may help avoid the "too many connection resets" error
109
- # when sending non-idempotent requests while increasing this value will cause
110
- # fewer round-trips.
111
- #
112
- # === Read Timeout
113
- #
114
- # The amount of time allowed between reading two chunks from the socket. Set
115
- # through #read_timeout
116
- #
117
- # === Max Requests
118
- #
119
- # The number of requests that should be made before opening a new connection.
120
- # Typically many keep-alive capable servers tune this to 100 or less, so the
121
- # 101st request will fail with ECONNRESET. If unset (default), this value has
122
- # no effect, if set, connections will be reset on the request after
123
- # max_requests.
124
- #
125
- # === Open Timeout
126
- #
127
- # The amount of time to wait for a connection to be opened. Set through
128
- # #open_timeout.
129
- #
130
- # === Socket Options
131
- #
132
- # Socket options may be set on newly-created connections. See #socket_options
133
- # for details.
134
- #
135
- # === Connection Termination
136
- #
137
- # If you are done using the Gem::Net::HTTP::Persistent instance you may shut down
138
- # all the connections in the current thread with #shutdown. This is not
139
- # recommended for normal use, it should only be used when it will be several
140
- # minutes before you make another HTTP request.
141
- #
142
- # If you are using multiple threads, call #shutdown in each thread when the
143
- # thread is done making requests. If you don't call shutdown, that's OK.
144
- # Ruby will automatically garbage collect and shutdown your HTTP connections
145
- # when the thread terminates.
146
-
147
- class Gem::Net::HTTP::Persistent
148
-
149
- ##
150
- # The beginning of Time
151
-
152
- EPOCH = Time.at 0 # :nodoc:
153
-
154
- ##
155
- # Is OpenSSL available? This test works with autoload
156
-
157
- HAVE_OPENSSL = defined? OpenSSL::SSL # :nodoc:
158
-
159
- ##
160
- # The default connection pool size is 1/4 the allowed open files
161
- # (<code>ulimit -n</code>) or 256 if your OS does not support file handle
162
- # limits (typically windows).
163
-
164
- if Process.const_defined? :RLIMIT_NOFILE
165
- open_file_limits = Process.getrlimit(Process::RLIMIT_NOFILE)
166
-
167
- # Under JRuby on Windows Process responds to `getrlimit` but returns something that does not match docs
168
- if open_file_limits.respond_to?(:first)
169
- DEFAULT_POOL_SIZE = open_file_limits.first / 4
170
- else
171
- DEFAULT_POOL_SIZE = 256
172
- end
173
- else
174
- DEFAULT_POOL_SIZE = 256
175
- end
176
-
177
- ##
178
- # The version of Gem::Net::HTTP::Persistent you are using
179
-
180
- VERSION = '4.0.8'
181
-
182
- ##
183
- # Error class for errors raised by Gem::Net::HTTP::Persistent. Various
184
- # SystemCallErrors are re-raised with a human-readable message under this
185
- # class.
186
-
187
- class Error < StandardError; end
188
-
189
- ##
190
- # Use this method to detect the idle timeout of the host at +uri+. The
191
- # value returned can be used to configure #idle_timeout. +max+ controls the
192
- # maximum idle timeout to detect.
193
- #
194
- # After
195
- #
196
- # Idle timeout detection is performed by creating a connection then
197
- # performing a HEAD request in a loop until the connection terminates
198
- # waiting one additional second per loop.
199
- #
200
- # NOTE: This may not work on ruby > 1.9.
201
-
202
- def self.detect_idle_timeout uri, max = 10
203
- uri = Gem::URI uri unless Gem::URI::Generic === uri
204
- uri += '/'
205
-
206
- req = Gem::Net::HTTP::Head.new uri.request_uri
207
-
208
- http = new 'net-http-persistent detect_idle_timeout'
209
-
210
- http.connection_for uri do |connection|
211
- sleep_time = 0
212
-
213
- http = connection.http
214
-
215
- loop do
216
- response = http.request req
217
-
218
- $stderr.puts "HEAD #{uri} => #{response.code}" if $DEBUG
219
-
220
- unless Gem::Net::HTTPOK === response then
221
- raise Error, "bad response code #{response.code} detecting idle timeout"
222
- end
223
-
224
- break if sleep_time >= max
225
-
226
- sleep_time += 1
227
-
228
- $stderr.puts "sleeping #{sleep_time}" if $DEBUG
229
- sleep sleep_time
230
- end
231
- end
232
- rescue
233
- # ignore StandardErrors, we've probably found the idle timeout.
234
- ensure
235
- return sleep_time unless $!
236
- end
237
-
238
- ##
239
- # This client's OpenSSL::X509::Certificate
240
-
241
- attr_reader :certificate
242
-
243
- ##
244
- # For Gem::Net::HTTP parity
245
-
246
- alias cert certificate
247
-
248
- ##
249
- # An SSL certificate authority. Setting this will set verify_mode to
250
- # VERIFY_PEER.
251
-
252
- attr_reader :ca_file
253
-
254
- ##
255
- # A directory of SSL certificates to be used as certificate authorities.
256
- # Setting this will set verify_mode to VERIFY_PEER.
257
-
258
- attr_reader :ca_path
259
-
260
- ##
261
- # An SSL certificate store. Setting this will override the default
262
- # certificate store. See verify_mode for more information.
263
-
264
- attr_reader :cert_store
265
-
266
- ##
267
- # The ciphers allowed for SSL connections
268
-
269
- attr_reader :ciphers
270
-
271
- ##
272
- # Extra certificates to be added to the certificate chain
273
-
274
- attr_reader :extra_chain_cert
275
-
276
- ##
277
- # Sends debug_output to this IO via Gem::Net::HTTP#set_debug_output.
278
- #
279
- # Never use this method in production code, it causes a serious security
280
- # hole.
281
-
282
- attr_accessor :debug_output
283
-
284
- ##
285
- # Current connection generation
286
-
287
- attr_reader :generation # :nodoc:
288
-
289
- ##
290
- # Headers that are added to every request using Gem::Net::HTTP#add_field
291
-
292
- attr_reader :headers
293
-
294
- ##
295
- # Maps host:port to an HTTP version. This allows us to enable version
296
- # specific features.
297
-
298
- attr_reader :http_versions
299
-
300
- ##
301
- # Maximum time an unused connection can remain idle before being
302
- # automatically closed.
303
-
304
- attr_accessor :idle_timeout
305
-
306
- ##
307
- # Maximum number of requests on a connection before it is considered expired
308
- # and automatically closed.
309
-
310
- attr_accessor :max_requests
311
-
312
- ##
313
- # Number of retries to perform if a request fails.
314
- #
315
- # See also #max_retries=, Gem::Net::HTTP#max_retries=.
316
-
317
- attr_reader :max_retries
318
-
319
- ##
320
- # The value sent in the Keep-Alive header. Defaults to 30. Not needed for
321
- # HTTP/1.1 servers.
322
- #
323
- # This may not work correctly for HTTP/1.0 servers
324
- #
325
- # This method may be removed in a future version as RFC 2616 does not
326
- # require this header.
327
-
328
- attr_accessor :keep_alive
329
-
330
- ##
331
- # The name for this collection of persistent connections.
332
-
333
- attr_reader :name
334
-
335
- ##
336
- # Seconds to wait until a connection is opened. See Gem::Net::HTTP#open_timeout
337
-
338
- attr_accessor :open_timeout
339
-
340
- ##
341
- # Headers that are added to every request using Gem::Net::HTTP#[]=
342
-
343
- attr_reader :override_headers
344
-
345
- ##
346
- # This client's SSL private key
347
-
348
- attr_reader :private_key
349
-
350
- ##
351
- # For Gem::Net::HTTP parity
352
-
353
- alias key private_key
354
-
355
- ##
356
- # The URL through which requests will be proxied
357
-
358
- attr_reader :proxy_uri
359
-
360
- ##
361
- # List of host suffixes which will not be proxied
362
-
363
- attr_reader :no_proxy
364
-
365
- ##
366
- # Test-only accessor for the connection pool
367
-
368
- attr_reader :pool # :nodoc:
369
-
370
- ##
371
- # Seconds to wait until reading one block. See Gem::Net::HTTP#read_timeout
372
-
373
- attr_accessor :read_timeout
374
-
375
- ##
376
- # Seconds to wait until writing one block. See Gem::Net::HTTP#write_timeout
377
-
378
- attr_accessor :write_timeout
379
-
380
- ##
381
- # By default SSL sessions are reused to avoid extra SSL handshakes. Set
382
- # this to false if you have problems communicating with an HTTPS server
383
- # like:
384
- #
385
- # SSL_connect [...] read finished A: unexpected message (OpenSSL::SSL::SSLError)
386
-
387
- attr_accessor :reuse_ssl_sessions
388
-
389
- ##
390
- # An array of options for Socket#setsockopt.
391
- #
392
- # By default the TCP_NODELAY option is set on sockets.
393
- #
394
- # To set additional options append them to this array:
395
- #
396
- # http.socket_options << [Socket::SOL_SOCKET, Socket::SO_KEEPALIVE, 1]
397
-
398
- attr_reader :socket_options
399
-
400
- ##
401
- # Current SSL connection generation
402
-
403
- attr_reader :ssl_generation # :nodoc:
404
-
405
- ##
406
- # SSL session lifetime
407
-
408
- attr_reader :ssl_timeout
409
-
410
- ##
411
- # SSL version to use.
412
- #
413
- # By default, the version will be negotiated automatically between client
414
- # and server. Ruby 1.9 and newer only. Deprecated since Ruby 2.5.
415
-
416
- attr_reader :ssl_version
417
-
418
- ##
419
- # Minimum SSL version to use, e.g. :TLS1_1
420
- #
421
- # By default, the version will be negotiated automatically between client
422
- # and server. Ruby 2.5 and newer only.
423
-
424
- attr_reader :min_version
425
-
426
- ##
427
- # Maximum SSL version to use, e.g. :TLS1_2
428
- #
429
- # By default, the version will be negotiated automatically between client
430
- # and server. Ruby 2.5 and newer only.
431
-
432
- attr_reader :max_version
433
-
434
- ##
435
- # Where this instance's last-use times live in the thread local variables
436
-
437
- attr_reader :timeout_key # :nodoc:
438
-
439
- ##
440
- # SSL verification callback. Used when ca_file or ca_path is set.
441
-
442
- attr_reader :verify_callback
443
-
444
- ##
445
- # Sets the depth of SSL certificate verification
446
-
447
- attr_reader :verify_depth
448
-
449
- ##
450
- # HTTPS verify mode. Defaults to OpenSSL::SSL::VERIFY_PEER which verifies
451
- # the server certificate.
452
- #
453
- # If no ca_file, ca_path or cert_store is set the default system certificate
454
- # store is used.
455
- #
456
- # You can use +verify_mode+ to override any default values.
457
-
458
- attr_reader :verify_mode
459
-
460
- ##
461
- # HTTPS verify_hostname.
462
- #
463
- # If a client sets this to true and enables SNI with SSLSocket#hostname=,
464
- # the hostname verification on the server certificate is performed
465
- # automatically during the handshake using
466
- # OpenSSL::SSL.verify_certificate_identity().
467
- #
468
- # You can set +verify_hostname+ as true to use hostname verification
469
- # during the handshake.
470
- #
471
- # NOTE: This works with Ruby > 3.0.
472
-
473
- attr_reader :verify_hostname
474
-
475
-
476
- ##
477
- # Sets whether to ignore end-of-file when reading a response body
478
- # with Content-Length headers.
479
-
480
- attr_accessor :ignore_eof
481
-
482
- ##
483
- # Creates a new Gem::Net::HTTP::Persistent.
484
- #
485
- # Set a +name+ for fun. Your library name should be good enough, but this
486
- # otherwise has no purpose.
487
- #
488
- # +proxy+ may be set to a Gem::URI::HTTP or :ENV to pick up proxy options from
489
- # the environment. See proxy_from_env for details.
490
- #
491
- # In order to use a Gem::URI for the proxy you may need to do some extra work
492
- # beyond Gem::URI parsing if the proxy requires a password:
493
- #
494
- # proxy = Gem::URI 'http://proxy.example'
495
- # proxy.user = 'AzureDiamond'
496
- # proxy.password = 'hunter2'
497
- #
498
- # Set +pool_size+ to limit the maximum number of connections allowed.
499
- # Defaults to 1/4 the number of allowed file handles or 256 if your OS does
500
- # not support a limit on allowed file handles. You can have no more than
501
- # this many threads with active HTTP transactions.
502
-
503
- def initialize name: nil, proxy: nil, pool_size: DEFAULT_POOL_SIZE
504
- @name = name
505
-
506
- @debug_output = nil
507
- @proxy_uri = nil
508
- @no_proxy = []
509
- @headers = {}
510
- @override_headers = {}
511
- @http_versions = {}
512
- @keep_alive = 30
513
- @open_timeout = nil
514
- @read_timeout = nil
515
- @write_timeout = nil
516
- @idle_timeout = 5
517
- @max_requests = nil
518
- @max_retries = 1
519
- @socket_options = []
520
- @ssl_generation = 0 # incremented when SSL session variables change
521
- @ignore_eof = nil
522
-
523
- @socket_options << [Socket::IPPROTO_TCP, Socket::TCP_NODELAY, 1] if
524
- Socket.const_defined? :TCP_NODELAY
525
-
526
- @pool = Gem::Net::HTTP::Persistent::Pool.new size: pool_size do |http_args|
527
- Gem::Net::HTTP::Persistent::Connection.new Gem::Net::HTTP, http_args, @ssl_generation
528
- end
529
-
530
- @certificate = nil
531
- @ca_file = nil
532
- @ca_path = nil
533
- @ciphers = nil
534
- @private_key = nil
535
- @ssl_timeout = nil
536
- @ssl_version = nil
537
- @min_version = nil
538
- @max_version = nil
539
- @verify_callback = nil
540
- @verify_depth = nil
541
- @verify_mode = nil
542
- @verify_hostname = nil
543
- @cert_store = nil
544
-
545
- @generation = 0 # incremented when proxy Gem::URI changes
546
-
547
- if HAVE_OPENSSL then
548
- @verify_mode = OpenSSL::SSL::VERIFY_PEER
549
- @reuse_ssl_sessions = OpenSSL::SSL.const_defined? :Session
550
- end
551
-
552
- self.proxy = proxy if proxy
553
- end
554
-
555
- ##
556
- # Sets this client's OpenSSL::X509::Certificate
557
-
558
- def certificate= certificate
559
- @certificate = certificate
560
-
561
- reconnect_ssl
562
- end
563
-
564
- # For Gem::Net::HTTP parity
565
- alias cert= certificate=
566
-
567
- ##
568
- # Sets the SSL certificate authority file.
569
-
570
- def ca_file= file
571
- @ca_file = file
572
-
573
- reconnect_ssl
574
- end
575
-
576
- ##
577
- # Sets the SSL certificate authority path.
578
-
579
- def ca_path= path
580
- @ca_path = path
581
-
582
- reconnect_ssl
583
- end
584
-
585
- ##
586
- # Overrides the default SSL certificate store used for verifying
587
- # connections.
588
-
589
- def cert_store= store
590
- @cert_store = store
591
-
592
- reconnect_ssl
593
- end
594
-
595
- ##
596
- # The ciphers allowed for SSL connections
597
-
598
- def ciphers= ciphers
599
- @ciphers = ciphers
600
-
601
- reconnect_ssl
602
- end
603
-
604
- if Gem::Net::HTTP.method_defined?(:extra_chain_cert=)
605
- ##
606
- # Extra certificates to be added to the certificate chain.
607
- # It is only supported starting from Gem::Net::HTTP version 0.1.1
608
- def extra_chain_cert= extra_chain_cert
609
- @extra_chain_cert = extra_chain_cert
610
-
611
- reconnect_ssl
612
- end
613
- else
614
- def extra_chain_cert= _extra_chain_cert
615
- raise "extra_chain_cert= is not supported by this version of Gem::Net::HTTP"
616
- end
617
- end
618
-
619
- ##
620
- # Creates a new connection for +uri+
621
-
622
- def connection_for uri
623
- use_ssl = uri.scheme.downcase == 'https'
624
-
625
- net_http_args = [uri.hostname, uri.port]
626
-
627
- # I'm unsure if uri.host or uri.hostname should be checked against
628
- # the proxy bypass list.
629
- if @proxy_uri and not proxy_bypass? uri.host, uri.port then
630
- net_http_args.concat @proxy_args
631
- else
632
- net_http_args.concat [nil, nil, nil, nil]
633
- end
634
-
635
- connection = @pool.checkout net_http_args
636
-
637
- begin
638
- http = connection.http
639
-
640
- connection.ressl @ssl_generation if
641
- connection.ssl_generation != @ssl_generation
642
-
643
- if not http.started? then
644
- ssl http if use_ssl
645
- start http
646
- elsif expired? connection then
647
- reset connection
648
- end
649
-
650
- http.ignore_eof = @ignore_eof if @ignore_eof
651
- http.keep_alive_timeout = @idle_timeout if @idle_timeout
652
- http.max_retries = @max_retries if http.respond_to?(:max_retries=)
653
- http.read_timeout = @read_timeout if @read_timeout
654
- http.write_timeout = @write_timeout if
655
- @write_timeout && http.respond_to?(:write_timeout=)
656
-
657
- return yield connection
658
- rescue Errno::ECONNREFUSED
659
- if http.proxy?
660
- address = http.proxy_address
661
- port = http.proxy_port
662
- else
663
- address = http.address
664
- port = http.port
665
- end
666
-
667
- raise Error, "connection refused: #{address}:#{port}"
668
- rescue Errno::EHOSTDOWN
669
- if http.proxy?
670
- address = http.proxy_address
671
- port = http.proxy_port
672
- else
673
- address = http.address
674
- port = http.port
675
- end
676
-
677
- raise Error, "host down: #{address}:#{port}"
678
- ensure
679
- @pool.checkin net_http_args
680
- end
681
- end
682
-
683
- ##
684
- # CGI::escape wrapper
685
-
686
- def escape str
687
- CGI.escape str if str
688
- end
689
-
690
- ##
691
- # CGI::unescape wrapper
692
-
693
- def unescape str
694
- CGI.unescape str if str
695
- end
696
-
697
-
698
- ##
699
- # Returns true if the connection should be reset due to an idle timeout, or
700
- # maximum request count, false otherwise.
701
-
702
- def expired? connection
703
- return true if @max_requests && connection.requests >= @max_requests
704
- return false unless @idle_timeout
705
- return true if @idle_timeout.zero?
706
-
707
- Time.now - connection.last_use > @idle_timeout
708
- end
709
-
710
- ##
711
- # Starts the Gem::Net::HTTP +connection+
712
-
713
- def start http
714
- http.set_debug_output @debug_output if @debug_output
715
- http.open_timeout = @open_timeout if @open_timeout
716
-
717
- http.start
718
-
719
- socket = http.instance_variable_get :@socket
720
-
721
- if socket then # for fakeweb
722
- @socket_options.each do |option|
723
- socket.io.setsockopt(*option)
724
- end
725
- end
726
- end
727
-
728
- ##
729
- # Finishes the Gem::Net::HTTP +connection+
730
-
731
- def finish connection
732
- connection.finish
733
-
734
- connection.http.instance_variable_set :@last_communicated, nil
735
- connection.http.instance_variable_set :@ssl_session, nil unless
736
- @reuse_ssl_sessions
737
- end
738
-
739
- ##
740
- # Returns the HTTP protocol version for +uri+
741
-
742
- def http_version uri
743
- @http_versions["#{uri.hostname}:#{uri.port}"]
744
- end
745
-
746
- ##
747
- # Adds "http://" to the String +uri+ if it is missing.
748
-
749
- def normalize_uri uri
750
- (uri =~ /^https?:/) ? uri : "http://#{uri}"
751
- end
752
-
753
- ##
754
- # Set the maximum number of retries for a request.
755
- #
756
- # Defaults to one retry.
757
- #
758
- # Set this to 0 to disable retries.
759
-
760
- def max_retries= retries
761
- retries = retries.to_int
762
-
763
- raise ArgumentError, "max_retries must be positive" if retries < 0
764
-
765
- @max_retries = retries
766
-
767
- reconnect
768
- end
769
-
770
- ##
771
- # Sets this client's SSL private key
772
-
773
- def private_key= key
774
- @private_key = key
775
-
776
- reconnect_ssl
777
- end
778
-
779
- # For Gem::Net::HTTP parity
780
- alias key= private_key=
781
-
782
- ##
783
- # Sets the proxy server. The +proxy+ may be the Gem::URI of the proxy server,
784
- # the symbol +:ENV+ which will read the proxy from the environment or nil to
785
- # disable use of a proxy. See #proxy_from_env for details on setting the
786
- # proxy from the environment.
787
- #
788
- # If the proxy Gem::URI is set after requests have been made, the next request
789
- # will shut-down and re-open all connections.
790
- #
791
- # The +no_proxy+ query parameter can be used to specify hosts which shouldn't
792
- # be reached via proxy; if set it should be a comma separated list of
793
- # hostname suffixes, optionally with +:port+ appended, for example
794
- # <tt>example.com,some.host:8080</tt>.
795
-
796
- def proxy= proxy
797
- @proxy_uri = case proxy
798
- when :ENV then proxy_from_env
799
- when Gem::URI::HTTP then proxy
800
- when nil then # ignore
801
- else raise ArgumentError, 'proxy must be :ENV or a Gem::URI::HTTP'
802
- end
803
-
804
- @no_proxy.clear
805
-
806
- if @proxy_uri then
807
- @proxy_args = [
808
- @proxy_uri.hostname,
809
- @proxy_uri.port,
810
- unescape(@proxy_uri.user),
811
- unescape(@proxy_uri.password),
812
- ]
813
-
814
- @proxy_connection_id = [nil, *@proxy_args].join ':'
815
-
816
- if @proxy_uri.query then
817
- @no_proxy = Gem::URI.decode_www_form(@proxy_uri.query).filter_map { |k, v| v if k == 'no_proxy' }.join(',').downcase.split(',').map { |x| x.strip }.reject { |x| x.empty? }
818
- end
819
- end
820
-
821
- reconnect
822
- reconnect_ssl
823
- end
824
-
825
- ##
826
- # Creates a Gem::URI for an HTTP proxy server from ENV variables.
827
- #
828
- # If +HTTP_PROXY+ is set a proxy will be returned.
829
- #
830
- # If +HTTP_PROXY_USER+ or +HTTP_PROXY_PASS+ are set the Gem::URI is given the
831
- # indicated user and password unless HTTP_PROXY contains either of these in
832
- # the Gem::URI.
833
- #
834
- # The +NO_PROXY+ ENV variable can be used to specify hosts which shouldn't
835
- # be reached via proxy; if set it should be a comma separated list of
836
- # hostname suffixes, optionally with +:port+ appended, for example
837
- # <tt>example.com,some.host:8080</tt>. When set to <tt>*</tt> no proxy will
838
- # be returned.
839
- #
840
- # For Windows users, lowercase ENV variables are preferred over uppercase ENV
841
- # variables.
842
-
843
- def proxy_from_env
844
- env_proxy = ENV['http_proxy'] || ENV['HTTP_PROXY']
845
-
846
- return nil if env_proxy.nil? or env_proxy.empty?
847
-
848
- uri = Gem::URI normalize_uri env_proxy
849
-
850
- env_no_proxy = ENV['no_proxy'] || ENV['NO_PROXY']
851
-
852
- # '*' is special case for always bypass
853
- return nil if env_no_proxy == '*'
854
-
855
- if env_no_proxy then
856
- uri.query = "no_proxy=#{escape(env_no_proxy)}"
857
- end
858
-
859
- unless uri.user or uri.password then
860
- uri.user = escape ENV['http_proxy_user'] || ENV['HTTP_PROXY_USER']
861
- uri.password = escape ENV['http_proxy_pass'] || ENV['HTTP_PROXY_PASS']
862
- end
863
-
864
- uri
865
- end
866
-
867
- ##
868
- # Returns true when proxy should by bypassed for host.
869
-
870
- def proxy_bypass? host, port
871
- host = host.downcase
872
- host_port = [host, port].join ':'
873
-
874
- @no_proxy.each do |name|
875
- return true if host[-name.length, name.length] == name or
876
- host_port[-name.length, name.length] == name
877
- end
878
-
879
- false
880
- end
881
-
882
- ##
883
- # Forces reconnection of all HTTP connections, including TLS/SSL
884
- # connections.
885
-
886
- def reconnect
887
- @generation += 1
888
- end
889
-
890
- ##
891
- # Forces reconnection of only TLS/SSL connections.
892
-
893
- def reconnect_ssl
894
- @ssl_generation += 1
895
- end
896
-
897
- ##
898
- # Finishes then restarts the Gem::Net::HTTP +connection+
899
-
900
- def reset connection
901
- http = connection.http
902
-
903
- finish connection
904
-
905
- start http
906
- rescue Errno::ECONNREFUSED
907
- e = Error.new "connection refused: #{http.address}:#{http.port}"
908
- e.set_backtrace $@
909
- raise e
910
- rescue Errno::EHOSTDOWN
911
- e = Error.new "host down: #{http.address}:#{http.port}"
912
- e.set_backtrace $@
913
- raise e
914
- end
915
-
916
- ##
917
- # Makes a request on +uri+. If +req+ is nil a Gem::Net::HTTP::Get is performed
918
- # against +uri+.
919
- #
920
- # If a block is passed #request behaves like Gem::Net::HTTP#request (the body of
921
- # the response will not have been read).
922
- #
923
- # +req+ must be a Gem::Net::HTTPGenericRequest subclass (see Gem::Net::HTTP for a list).
924
-
925
- def request uri, req = nil, &block
926
- uri = Gem::URI uri
927
- req = request_setup req || uri
928
- response = nil
929
-
930
- connection_for uri do |connection|
931
- http = connection.http
932
-
933
- begin
934
- connection.requests += 1
935
-
936
- response = http.request req, &block
937
-
938
- if req.connection_close? or
939
- (response.http_version <= '1.0' and
940
- not response.connection_keep_alive?) or
941
- response.connection_close? then
942
- finish connection
943
- end
944
- rescue Exception # make sure to close the connection when it was interrupted
945
- finish connection
946
-
947
- raise
948
- ensure
949
- connection.last_use = Time.now
950
- end
951
- end
952
-
953
- @http_versions["#{uri.hostname}:#{uri.port}"] ||= response.http_version
954
-
955
- response
956
- end
957
-
958
- ##
959
- # Creates a GET request if +req_or_uri+ is a Gem::URI and adds headers to the
960
- # request.
961
- #
962
- # Returns the request.
963
-
964
- def request_setup req_or_uri # :nodoc:
965
- req = if req_or_uri.respond_to? 'request_uri' then
966
- Gem::Net::HTTP::Get.new req_or_uri.request_uri
967
- else
968
- req_or_uri
969
- end
970
-
971
- @headers.each do |pair|
972
- req.add_field(*pair)
973
- end
974
-
975
- @override_headers.each do |name, value|
976
- req[name] = value
977
- end
978
-
979
- unless req['Connection'] then
980
- req.add_field 'Connection', 'keep-alive'
981
- req.add_field 'Keep-Alive', @keep_alive
982
- end
983
-
984
- req
985
- end
986
-
987
- ##
988
- # Shuts down all connections. Attempting to checkout a connection after
989
- # shutdown will raise an error.
990
- #
991
- # *NOTE*: Calling shutdown for can be dangerous!
992
- #
993
- # If any thread is still using a connection it may cause an error! Call
994
- # #shutdown when you are completely done making requests!
995
-
996
- def shutdown
997
- @pool.shutdown { |http| http.finish }
998
- end
999
-
1000
- ##
1001
- # Discard all existing connections. Subsequent checkouts will create
1002
- # new connections as needed.
1003
- #
1004
- # If any thread is still using a connection it may cause an error! Call
1005
- # #reload when you are completely done making requests!
1006
-
1007
- def reload
1008
- @pool.reload { |http| http.finish }
1009
- end
1010
-
1011
- ##
1012
- # Enables SSL on +connection+
1013
-
1014
- def ssl connection
1015
- connection.use_ssl = true
1016
-
1017
- connection.ciphers = @ciphers if @ciphers
1018
- connection.ssl_timeout = @ssl_timeout if @ssl_timeout
1019
- connection.ssl_version = @ssl_version if @ssl_version
1020
- connection.min_version = @min_version if @min_version
1021
- connection.max_version = @max_version if @max_version
1022
-
1023
- connection.verify_depth = @verify_depth
1024
- connection.verify_mode = @verify_mode
1025
- connection.verify_hostname = @verify_hostname if
1026
- @verify_hostname != nil && connection.respond_to?(:verify_hostname=)
1027
-
1028
- if OpenSSL::SSL::VERIFY_PEER == OpenSSL::SSL::VERIFY_NONE and
1029
- not Object.const_defined?(:I_KNOW_THAT_OPENSSL_VERIFY_PEER_EQUALS_VERIFY_NONE_IS_WRONG) then
1030
- warn <<-WARNING
1031
- !!!SECURITY WARNING!!!
1032
-
1033
- The SSL HTTP connection to:
1034
-
1035
- #{connection.address}:#{connection.port}
1036
-
1037
- !!!MAY NOT BE VERIFIED!!!
1038
-
1039
- On your platform your OpenSSL implementation is broken.
1040
-
1041
- There is no difference between the values of VERIFY_NONE and VERIFY_PEER.
1042
-
1043
- This means that attempting to verify the security of SSL connections may not
1044
- work. This exposes you to man-in-the-middle exploits, snooping on the
1045
- contents of your connection and other dangers to the security of your data.
1046
-
1047
- To disable this warning define the following constant at top-level in your
1048
- application:
1049
-
1050
- I_KNOW_THAT_OPENSSL_VERIFY_PEER_EQUALS_VERIFY_NONE_IS_WRONG = nil
1051
-
1052
- WARNING
1053
- end
1054
-
1055
- connection.ca_file = @ca_file if @ca_file
1056
- connection.ca_path = @ca_path if @ca_path
1057
-
1058
- if @ca_file or @ca_path then
1059
- connection.verify_mode = OpenSSL::SSL::VERIFY_PEER
1060
- connection.verify_callback = @verify_callback if @verify_callback
1061
- end
1062
-
1063
- if @certificate and @private_key then
1064
- connection.cert = @certificate
1065
- connection.key = @private_key
1066
- end
1067
-
1068
- if defined?(@extra_chain_cert) and @extra_chain_cert
1069
- connection.extra_chain_cert = @extra_chain_cert
1070
- end
1071
-
1072
- connection.cert_store = if @cert_store then
1073
- @cert_store
1074
- else
1075
- store = OpenSSL::X509::Store.new
1076
- store.set_default_paths
1077
- store
1078
- end
1079
- end
1080
-
1081
- ##
1082
- # SSL session lifetime
1083
-
1084
- def ssl_timeout= ssl_timeout
1085
- @ssl_timeout = ssl_timeout
1086
-
1087
- reconnect_ssl
1088
- end
1089
-
1090
- ##
1091
- # SSL version to use
1092
-
1093
- def ssl_version= ssl_version
1094
- @ssl_version = ssl_version
1095
-
1096
- reconnect_ssl
1097
- end
1098
-
1099
- ##
1100
- # Minimum SSL version to use
1101
-
1102
- def min_version= min_version
1103
- @min_version = min_version
1104
-
1105
- reconnect_ssl
1106
- end
1107
-
1108
- ##
1109
- # maximum SSL version to use
1110
-
1111
- def max_version= max_version
1112
- @max_version = max_version
1113
-
1114
- reconnect_ssl
1115
- end
1116
-
1117
- ##
1118
- # Sets the depth of SSL certificate verification
1119
-
1120
- def verify_depth= verify_depth
1121
- @verify_depth = verify_depth
1122
-
1123
- reconnect_ssl
1124
- end
1125
-
1126
- ##
1127
- # Sets the HTTPS verify mode. Defaults to OpenSSL::SSL::VERIFY_PEER.
1128
- #
1129
- # Setting this to VERIFY_NONE is a VERY BAD IDEA and should NEVER be used.
1130
- # Securely transfer the correct certificate and update the default
1131
- # certificate store or set the ca file instead.
1132
-
1133
- def verify_mode= verify_mode
1134
- @verify_mode = verify_mode
1135
-
1136
- reconnect_ssl
1137
- end
1138
-
1139
- ##
1140
- # Sets the HTTPS verify_hostname.
1141
-
1142
- def verify_hostname= verify_hostname
1143
- @verify_hostname = verify_hostname
1144
-
1145
- reconnect_ssl
1146
- end
1147
-
1148
- ##
1149
- # SSL verification callback.
1150
-
1151
- def verify_callback= callback
1152
- @verify_callback = callback
1153
-
1154
- reconnect_ssl
1155
- end
1156
- end
1157
-
1158
- require_relative 'persistent/connection'
1159
- require_relative 'persistent/pool'