puma 4.0.0 → 4.1.1

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of puma might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b22a5ddb0ac910e28c3789564c70be998eaa0dec5eca7c668c6a4478ab35012b
4
- data.tar.gz: b98d67fb71305279ee8169c80546e46d4b63a4be522462545023f8917d82fa72
3
+ metadata.gz: e85f11b3b0951de326c5bba3f9f11c77bd1f4b28d6bc82d0f33ba8c6f7ebfd2d
4
+ data.tar.gz: 481c1977d845730e2fe5f1186861b6e31f6fe5141f9b90b1d5269a4fcb293657
5
5
  SHA512:
6
- metadata.gz: 1f7186d10e0783ffd899b65b25fdda553346074b3bad7416726a99a0f77709318a275e67856beb101ff75c9b75dba48af917d48504bf6f5fc15b64dd7c8a190a
7
- data.tar.gz: 1881c9c149c4e631c9bec14cd92344785933c81bf4fb997721c61081d4a3f6f9a5bf4cbf0f8faca44110deaa7331b6177a67d734af3006b1e0b677a7782fc5f9
6
+ metadata.gz: 25f5a271f646bb1d4695279a5fa21a5be43639a01bcd6647adc484f84e84fc2a227097278da57456bf81de4996c749c0f6c80f9fd249e24a79555e44431bb19b
7
+ data.tar.gz: 2defc82769f5c36810f21aaf3f93aaad52e9073e55cb8f19aa0dbc4cfc2dcab37fd0cf458aef58b2025626ff4a59174aff7fa0faa9ebe5a3333fa7dd69ff5df7
data/History.md CHANGED
@@ -1,11 +1,56 @@
1
1
  ## Master
2
2
 
3
- x features
4
- x bugfixes
3
+ * Features
4
+ * Your feature goes here (#Github Number)
5
+
6
+ * Bugfixes
7
+ * Your bugfix goes here (#Github Number)
8
+
9
+ ## 4.1.1 / 2019-09-05
10
+
11
+ * 3 bugfixes
12
+ * Revert our attempt to not dup STDOUT/STDERR (#1946)
13
+ * Fix socket close on error (#1941)
14
+ * Fix workers not shutting down correctly (#1908)
15
+
16
+ ## 4.1.0 / 2019-08-08
17
+
18
+ * 4 features
19
+ * Add REQUEST_PATH on parse error message (#1831)
20
+ * You can now easily add custom log formatters with the `log_formatter` config option (#1816)
21
+ * Puma.stats now provides process start times (#1844)
22
+ * Add support for disabling TLSv1.1 (#1836)
23
+
24
+ * 7 bugfixes
25
+ * Fix issue where Puma was creating zombie process entries (#1887)
26
+ * Fix bugs with line-endings and chunked encoding (#1812)
27
+ * RACK_URL_SCHEME is now set correctly in all conditions (#1491)
28
+ * We no longer mutate global STDOUT/STDERR, particularly the sync setting (#1837)
29
+ * SSL read_nonblock no longer blocks (#1857)
30
+ * Swallow connection errors when sending early hints (#1822)
31
+ * Backtrace no longer dumped when invalid pumactl commands are run (#1863)
32
+
33
+ * 5 other
34
+ * Avoid casting worker_timeout twice (#1838)
35
+ * Removed a call to private that wasn't doing anything (#1882)
36
+ * README, Rakefile, docs and test cleanups (#1848, #1847, #1846, #1853, #1859, #1850, #1866, #1870, #1872, #1833, #1888)
37
+ * Puma.io has proper documentation now (https://puma.io/puma/)
38
+ * Added the Contributor Covenant CoC
39
+
40
+ * 1 known issue
41
+ * Some users are still experiencing issues surrounding socket activation and Unix sockets (#1842)
42
+
43
+ ## 4.0.1 / 2019-07-11
44
+
45
+ * 2 bugfixes
46
+ * Fix socket removed after reload - should fix problems with systemd socket activation. (#1829)
47
+ * Add extconf tests for DTLS_method & TLS_server_method, use in minissl.rb. Should fix "undefined symbol: DTLS_method" when compiling against old OpenSSL versions. (#1832)
48
+ * 1 other
49
+ * Removed unnecessary RUBY_VERSION checks. (#1827)
5
50
 
6
51
  ## 4.0.0 / 2019-06-25
7
52
 
8
- 9 features
53
+ * 9 features
9
54
  * Add support for disabling TLSv1.0 (#1562)
10
55
  * Request body read time metric (#1569)
11
56
  * Add out_of_band hook (#1648)
@@ -14,7 +59,9 @@ x bugfixes
14
59
  * Add option to suppress SignalException on SIGTERM (#1690)
15
60
  * Allow mutual TLS CA to be set using `ssl_bind` DSL (#1689)
16
61
  * Reactor now uses nio4r instead of `select` (#1728)
17
- 9 x bugfixes
62
+ * Add status to pumactl with pidfile (#1824)
63
+
64
+ * 9 bugfixes
18
65
  * Do not accept new requests on shutdown (#1685, #1808)
19
66
  * Fix 3 corner cases when request body is chunked (#1508)
20
67
  * Change pid existence check's condition branches (#1650)
@@ -1431,3 +1478,12 @@ be added back in a future date when a java Puma::MiniSSL is added.
1431
1478
  ## 1.0.0 / 2012-03-29
1432
1479
 
1433
1480
  * Released!
1481
+
1482
+ ## Ignore - this is for maintainers to copy-paste during release
1483
+ ## Master
1484
+
1485
+ * Features
1486
+ * Your feature goes here (#Github Number)
1487
+
1488
+ * Bugfixes
1489
+ * Your bugfix goes here (#Github Number)
data/README.md CHANGED
@@ -10,36 +10,38 @@
10
10
  [![Code Climate](https://codeclimate.com/github/puma/puma.svg)](https://codeclimate.com/github/puma/puma)
11
11
  [![SemVer](https://api.dependabot.com/badges/compatibility_score?dependency-name=puma&package-manager=bundler&version-scheme=semver)](https://dependabot.com/compatibility-score.html?dependency-name=puma&package-manager=bundler&version-scheme=semver)
12
12
 
13
- Puma is a **simple, fast, threaded, and highly concurrent HTTP 1.1 server for Ruby/Rack applications** in development and production.
13
+ Puma is a **simple, fast, multi-threaded, and highly concurrent HTTP 1.1 server for Ruby/Rack applications**.
14
14
 
15
15
  ## Built For Speed & Concurrency
16
16
 
17
- Under the hood, Puma processes requests using a C-optimized Ragel extension (inherited from Mongrel) that provides fast, accurate HTTP 1.1 protocol parsing in a portable way. Puma then serves the request in a thread from an internal thread pool. Since each request is served in a separate thread, truly concurrent Ruby implementations (JRuby, Rubinius) will use all available CPU cores.
17
+ Puma processes requests using a C-optimized Ragel extension (inherited from Mongrel) that provides fast, accurate HTTP 1.1 protocol parsing in a portable way. Puma then serves the request using a thread pool. Each request is served in a separate thread, so truly concurrent Ruby implementations (JRuby, Rubinius) will use all available CPU cores.
18
18
 
19
19
  Puma was designed to be the go-to server for [Rubinius](https://rubini.us), but also works well with JRuby and MRI.
20
20
 
21
- On MRI, there is a Global VM Lock (GVL) that ensures only one thread can run Ruby code at a time. But if you're doing a lot of blocking IO (such as HTTP calls to external APIs like Twitter), Puma still improves MRI's throughput by allowing blocking IO to be run concurrently.
21
+ On MRI, there is a Global VM Lock (GVL) that ensures only one thread can run Ruby code at a time. But if you're doing a lot of blocking IO (such as HTTP calls to external APIs like Twitter), Puma still improves MRI's throughput by allowing IO waiting to be done in parallel.
22
22
 
23
23
  ## Quick Start
24
24
 
25
25
  ```
26
26
  $ gem install puma
27
- $ puma <any rackup (*.ru) file>
27
+ $ puma
28
28
  ```
29
29
 
30
+ Without arguments, puma will look for a rackup (.ru) file in the current working directory called `config.ru`.
31
+
30
32
  ## Frameworks
31
33
 
32
34
  ### Rails
33
35
 
34
- Puma is the default server for Rails, and should already be included in your Gemfile.
36
+ Puma is the default server for Rails, included in the generated Gemfile.
35
37
 
36
- Then start your server with the `rails` command:
38
+ Start your server with the `rails` command:
37
39
 
38
40
  ```
39
- $ rails s
41
+ $ rails server
40
42
  ```
41
43
 
42
- Many configuration options are not available when using `rails s`. It is recommended that you use Puma's executable instead:
44
+ Many configuration options and Puma features are not available when using `rails server`. It is recommended that you use Puma's executable instead:
43
45
 
44
46
  ```
45
47
  $ bundle exec puma
@@ -53,7 +55,7 @@ You can run your Sinatra application with Puma from the command line like this:
53
55
  $ ruby app.rb -s Puma
54
56
  ```
55
57
 
56
- Or you can configure your application to always use Puma:
58
+ Or you can configure your Sinatra application to always use Puma:
57
59
 
58
60
  ```ruby
59
61
  require 'sinatra'
@@ -64,6 +66,9 @@ configure { set :server, :puma }
64
66
 
65
67
  Puma provides numerous options. Consult `puma -h` (or `puma --help`) for a full list of CLI options, or see [dsl.rb](https://github.com/puma/puma/blob/master/lib/puma/dsl.rb).
66
68
 
69
+ You can also find several configuration examples as part of the
70
+ [test](test/config) suite.
71
+
67
72
  ### Thread Pool
68
73
 
69
74
  Puma uses a thread pool. You can set the minimum and maximum number of threads that are available in the pool with the `-t` (or `--threads`) flag:
@@ -72,9 +77,9 @@ Puma uses a thread pool. You can set the minimum and maximum number of threads t
72
77
  $ puma -t 8:32
73
78
  ```
74
79
 
75
- Puma will automatically scale the number of threads, from the minimum until it caps out at the maximum, based on how much traffic is present. The current default is `0:16`. Feel free to experiment, but be careful not to set the number of maximum threads to a large number, as you may exhaust resources on the system (or hit resource limits).
80
+ Puma will automatically scale the number of threads, from the minimum until it caps out at the maximum, based on how much traffic is present. The current default is `0:16`. Feel free to experiment, but be careful not to set the number of maximum threads to a large number, as you may exhaust resources on the system (or cause contention for the Global VM Lock, when using MRI).
76
81
 
77
- Be aware that additionally Puma creates threads on its own for internal purposes (e.g. handling slow clients). So even if you specify -t 1:1, expect around 7 threads created in your application.
82
+ Be aware that additionally Puma creates threads on its own for internal purposes (e.g. handling slow clients). So, even if you specify -t 1:1, expect around 7 threads created in your application.
78
83
 
79
84
  ### Clustered mode
80
85
 
@@ -84,9 +89,9 @@ Puma also offers "clustered mode". Clustered mode `fork`s workers from a master
84
89
  $ puma -t 8:32 -w 3
85
90
  ```
86
91
 
87
- Note that threads are still used in clustered mode, and the `-t` thread flag setting is per worker, so `-w 2 -t 16:16` will spawn 32 threads in total.
92
+ Note that threads are still used in clustered mode, and the `-t` thread flag setting is per worker, so `-w 2 -t 16:16` will spawn 32 threads in total, with 16 in each worker process.
88
93
 
89
- In clustered mode, Puma may "preload" your application. This loads all the application code *prior* to forking. Preloading reduces total memory usage of your application via an operating system feature called [copy-on-write](https://en.wikipedia.org/wiki/Copy-on-write) (Ruby 2.0+ only). Use the `--preload` flag from the command line:
94
+ In clustered mode, Puma can "preload" your application. This loads all the application code *prior* to forking. Preloading reduces total memory usage of your application via an operating system feature called [copy-on-write](https://en.wikipedia.org/wiki/Copy-on-write) (Ruby 2.0+ only). Use the `--preload` flag from the command line:
90
95
 
91
96
  ```
92
97
  $ puma -w 3 --preload
@@ -111,8 +116,7 @@ end
111
116
 
112
117
  This code can be used to setup the process before booting the application, allowing
113
118
  you to do some Puma-specific things that you don't want to embed in your application.
114
- For instance, you could fire a log notification that a worker booted or send something to statsd.
115
- This can be called multiple times.
119
+ For instance, you could fire a log notification that a worker booted or send something to statsd. This can be called multiple times.
116
120
 
117
121
  If you're preloading your application and using ActiveRecord, it's recommended that you setup your connection pool here:
118
122
 
@@ -125,7 +129,7 @@ on_worker_boot do
125
129
  end
126
130
  ```
127
131
 
128
- On top of that, you can specify a block in your configuration file that will be run before workers are forked:
132
+ `before_fork` specifies a block to be run before workers are forked:
129
133
 
130
134
  ```ruby
131
135
  # config/puma.rb
@@ -136,15 +140,29 @@ end
136
140
 
137
141
  Preloading can’t be used with phased restart, since phased restart kills and restarts workers one-by-one, and preload_app copies the code of master into the workers.
138
142
 
143
+ ### Error handling
144
+
145
+ If puma encounters an error outside of the context of your application, it will respond with a 500 and a simple
146
+ textual error message (see `lowlevel_error` in [this file](https://github.com/puma/puma/blob/master/lib/puma/server.rb)).
147
+ You can specify custom behavior for this scenario. For example, you can report the error to your third-party
148
+ error-tracking service (in this example, [rollbar](http://rollbar.com)):
149
+
150
+ ```ruby
151
+ lowlevel_error_handler do |e|
152
+ Rollbar.critical(e)
153
+ [500, {}, ["An error has occurred, and engineers have been informed. Please reload the page. If you continue to have problems, contact support@example.com\n"]]
154
+ end
155
+ ```
156
+
139
157
  ### Binding TCP / Sockets
140
158
 
141
- In contrast to many other server configs which require multiple flags, Puma simply uses one URI parameter with the `-b` (or `--bind`) flag:
159
+ Bind Puma to a socket with the `-b` (or `--bind`) flag:
142
160
 
143
161
  ```
144
162
  $ puma -b tcp://127.0.0.1:9292
145
163
  ```
146
164
 
147
- Want to use UNIX Sockets instead of TCP (which can provide a 5-10% performance boost)?
165
+ To use a UNIX Socket instead of TCP:
148
166
 
149
167
  ```
150
168
  $ puma -b unix:///var/run/puma.sock
@@ -157,13 +175,14 @@ $ puma -b 'unix:///var/run/puma.sock?umask=0111'
157
175
  ```
158
176
 
159
177
  Need a bit of security? Use SSL sockets:
178
+
160
179
  ```
161
180
  $ puma -b 'ssl://127.0.0.1:9292?key=path_to_key&cert=path_to_cert'
162
181
  ```
163
182
 
164
183
  #### Controlling SSL Cipher Suites
165
184
 
166
- Need to use or avoid specific SSL cipher suites? Use `ssl_cipher_filter` or `ssl_cipher_list` options.
185
+ To use or avoid specific SSL cipher suites, use `ssl_cipher_filter` or `ssl_cipher_list` options.
167
186
 
168
187
  ##### Ruby:
169
188
 
@@ -179,7 +198,7 @@ $ puma -b 'ssl://127.0.0.1:9292?keystore=path_to_keystore&keystore-pass=keystore
179
198
 
180
199
  See https://www.openssl.org/docs/man1.0.2/apps/ciphers.html for cipher filter format and full list of cipher suites.
181
200
 
182
- Don't want to use insecure TLSv1.0 ?
201
+ Disable TLS v1 with the `no_tlsv1` option:
183
202
 
184
203
  ```
185
204
  $ puma -b 'ssl://127.0.0.1:9292?key=path_to_key&cert=path_to_cert&no_tlsv1=true'
@@ -187,13 +206,13 @@ $ puma -b 'ssl://127.0.0.1:9292?key=path_to_key&cert=path_to_cert&no_tlsv1=true'
187
206
 
188
207
  ### Control/Status Server
189
208
 
190
- Puma has a built-in status/control app that can be used to query and control Puma itself.
209
+ Puma has a built-in status and control app that can be used to query and control Puma.
191
210
 
192
211
  ```
193
212
  $ puma --control-url tcp://127.0.0.1:9293 --control-token foo
194
213
  ```
195
214
 
196
- Puma will start the control server on localhost port 9293. All requests to the control server will need to include `token=foo` as a query parameter. This allows for simple authentication. Check out [status.rb](https://github.com/puma/puma/blob/master/lib/puma/app/status.rb) to see what the app has available.
215
+ Puma will start the control server on localhost port 9293. All requests to the control server will need to include control token (in this case, `token=foo`) as a query parameter. This allows for simple authentication. Check out [status.rb](https://github.com/puma/puma/blob/master/lib/puma/app/status.rb) to see what the status app has available.
197
216
 
198
217
  You can also interact with the control server via `pumactl`. This command will restart Puma:
199
218
 
@@ -205,13 +224,13 @@ To see a list of `pumactl` options, use `pumactl --help`.
205
224
 
206
225
  ### Configuration File
207
226
 
208
- You can also provide a configuration file which Puma will use with the `-C` (or `--config`) flag:
227
+ You can also provide a configuration file with the `-C` (or `--config`) flag:
209
228
 
210
229
  ```
211
230
  $ puma -C /path/to/config
212
231
  ```
213
232
 
214
- If no configuration file is specified, Puma will look for a configuration file at `config/puma.rb`. If an environment is specified, either via the `-e` and `--environment` flags, or through the `RACK_ENV` environment variable, the default file location will be `config/puma/environment_name.rb`.
233
+ If no configuration file is specified, Puma will look for a configuration file at `config/puma.rb`. If an environment is specified, either via the `-e` and `--environment` flags, or through the `RACK_ENV` environment variable, Puma looks for configuration at `config/puma/<environment_name>.rb`.
215
234
 
216
235
  If you want to prevent Puma from looking for a configuration file in those locations, provide a dash as the argument to the `-C` (or `--config`) flag:
217
236
 
@@ -219,7 +238,7 @@ If you want to prevent Puma from looking for a configuration file in those locat
219
238
  $ puma -C "-"
220
239
  ```
221
240
 
222
- Take the following [sample configuration](https://github.com/puma/puma/blob/master/examples/config.rb) as inspiration or check out [dsl.rb](https://github.com/puma/puma/blob/master/lib/puma/dsl.rb) to see all available options.
241
+ Check out [dsl.rb](https://github.com/puma/puma/blob/master/lib/puma/dsl.rb) to see all available options.
223
242
 
224
243
  ## Restart
225
244
 
@@ -236,7 +255,7 @@ Puma responds to several signals. A detailed guide to using UNIX signals with Pu
236
255
  Some platforms do not support all Puma features.
237
256
 
238
257
  * **JRuby**, **Windows**: server sockets are not seamless on restart, they must be closed and reopened. These platforms have no way to pass descriptors into a new process that is exposed to Ruby. Also, cluster mode is not supported due to a lack of fork(2).
239
- * **Windows**: daemon mode is not supported due to a lack of fork(2).
258
+ * **Windows**: Cluster mode is not supported due to a lack of fork(2).
240
259
 
241
260
  ## Known Bugs
242
261
 
@@ -278,6 +297,24 @@ $ bundle install
278
297
  $ bundle exec rake
279
298
  ```
280
299
 
300
+ To run a single test file, use the `TEST` environment variable:
301
+
302
+ ```bash
303
+ $ TEST=test/test_binder.rb bundle exec rake test
304
+ ```
305
+
306
+ Or use [`m`](https://github.com/qrush/m):
307
+
308
+ ```
309
+ $ bundle exec m test/test_binder.rb
310
+ ```
311
+
312
+ Which can also be used to run a single test case:
313
+
314
+ ```
315
+ $ bundle exec m test/test_binder.rb:37
316
+ ```
317
+
281
318
  ## License
282
319
 
283
320
  Puma is copyright Evan Phoenix and contributors, licensed under the BSD 3-Clause license. See the included LICENSE file for details.
@@ -9,6 +9,14 @@ unless ENV["DISABLE_SSL"]
9
9
  %w'ssl ssleay32'.find {|ssl| have_library(ssl, 'SSL_CTX_new')}
10
10
 
11
11
  have_header "openssl/bio.h"
12
+
13
+ # below is yes for 1.0.2 & later
14
+ have_func "DTLS_method" , "openssl/ssl.h"
15
+
16
+ # below are yes for 1.1.0 & later, may need to check func rather than macro
17
+ # with versions after 1.1.1
18
+ have_func "TLS_server_method" , "openssl/ssl.h"
19
+ have_macro "SSL_CTX_set_min_proto_version", "openssl/ssl.h"
12
20
  end
13
21
  end
14
22
 
@@ -142,7 +142,7 @@ VALUE engine_init_server(VALUE self, VALUE mini_ssl_ctx) {
142
142
  VALUE obj;
143
143
  SSL_CTX* ctx;
144
144
  SSL* ssl;
145
- int ssl_options;
145
+ int min, ssl_options;
146
146
 
147
147
  ms_conn* conn = engine_alloc(self, &obj);
148
148
 
@@ -168,8 +168,14 @@ VALUE engine_init_server(VALUE self, VALUE mini_ssl_ctx) {
168
168
  ID sym_no_tlsv1 = rb_intern("no_tlsv1");
169
169
  VALUE no_tlsv1 = rb_funcall(mini_ssl_ctx, sym_no_tlsv1, 0);
170
170
 
171
+ ID sym_no_tlsv1_1 = rb_intern("no_tlsv1_1");
172
+ VALUE no_tlsv1_1 = rb_funcall(mini_ssl_ctx, sym_no_tlsv1_1, 0);
171
173
 
174
+ #ifdef HAVE_TLS_SERVER_METHOD
175
+ ctx = SSL_CTX_new(TLS_server_method());
176
+ #else
172
177
  ctx = SSL_CTX_new(SSLv23_server_method());
178
+ #endif
173
179
  conn->ctx = ctx;
174
180
 
175
181
  SSL_CTX_use_certificate_chain_file(ctx, RSTRING_PTR(cert));
@@ -180,12 +186,36 @@ VALUE engine_init_server(VALUE self, VALUE mini_ssl_ctx) {
180
186
  SSL_CTX_load_verify_locations(ctx, RSTRING_PTR(ca), NULL);
181
187
  }
182
188
 
183
- ssl_options = SSL_OP_CIPHER_SERVER_PREFERENCE | SSL_OP_NO_SSLv2 | SSL_OP_NO_SSLv3 | SSL_OP_SINGLE_DH_USE | SSL_OP_SINGLE_ECDH_USE | SSL_OP_NO_COMPRESSION;
189
+ ssl_options = SSL_OP_CIPHER_SERVER_PREFERENCE | SSL_OP_SINGLE_ECDH_USE | SSL_OP_NO_COMPRESSION;
190
+
191
+ #ifdef HAVE_SSL_CTX_SET_MIN_PROTO_VERSION
192
+ if (RTEST(no_tlsv1_1)) {
193
+ min = TLS1_2_VERSION;
194
+ }
195
+ else if (RTEST(no_tlsv1)) {
196
+ min = TLS1_1_VERSION;
197
+ }
198
+ else {
199
+ min = TLS1_VERSION;
200
+ }
201
+
202
+ SSL_CTX_set_min_proto_version(ctx, min);
203
+
204
+ SSL_CTX_set_options(ctx, ssl_options);
184
205
 
185
- if(RTEST(no_tlsv1)) {
206
+ #else
207
+ /* As of 1.0.2f, SSL_OP_SINGLE_DH_USE key use is always on */
208
+ ssl_options |= SSL_OP_NO_SSLv2 | SSL_OP_NO_SSLv3 | SSL_OP_SINGLE_DH_USE;
209
+
210
+ if (RTEST(no_tlsv1)) {
186
211
  ssl_options |= SSL_OP_NO_TLSv1;
187
212
  }
213
+ if(RTEST(no_tlsv1_1)) {
214
+ ssl_options |= SSL_OP_NO_TLSv1 | SSL_OP_NO_TLSv1_1;
215
+ }
188
216
  SSL_CTX_set_options(ctx, ssl_options);
217
+ #endif
218
+
189
219
  SSL_CTX_set_session_cache_mode(ctx, SSL_SESS_CACHE_OFF);
190
220
 
191
221
  if (!NIL_P(ssl_cipher_filter)) {
@@ -232,8 +262,11 @@ VALUE engine_init_server(VALUE self, VALUE mini_ssl_ctx) {
232
262
  VALUE engine_init_client(VALUE klass) {
233
263
  VALUE obj;
234
264
  ms_conn* conn = engine_alloc(klass, &obj);
235
-
265
+ #ifdef HAVE_DTLS_METHOD
236
266
  conn->ctx = SSL_CTX_new(DTLS_method());
267
+ #else
268
+ conn->ctx = SSL_CTX_new(DTLSv1_method());
269
+ #endif
237
270
  conn->ssl = SSL_new(conn->ctx);
238
271
  SSL_set_app_data(conn->ssl, NULL);
239
272
  SSL_set_verify(conn->ssl, SSL_VERIFY_NONE, NULL);
@@ -452,14 +485,35 @@ void Init_mini_ssl(VALUE puma) {
452
485
  // OpenSSL Build / Runtime/Load versions
453
486
 
454
487
  /* Version of OpenSSL that Puma was compiled with */
455
- rb_define_const(mod, "OPENSSL_VERSION", rb_str_new2(OPENSSL_VERSION_TEXT));
488
+ rb_define_const(mod, "OPENSSL_VERSION", rb_str_new2(OPENSSL_VERSION_TEXT));
456
489
 
457
490
  #if !defined(LIBRESSL_VERSION_NUMBER) && OPENSSL_VERSION_NUMBER >= 0x10100000
458
- /* Version of OpenSSL that Puma loaded with */
459
- rb_define_const(mod, "OPENSSL_LIBRARY_VERSION", rb_str_new2(OpenSSL_version(OPENSSL_VERSION)));
491
+ /* Version of OpenSSL that Puma loaded with */
492
+ rb_define_const(mod, "OPENSSL_LIBRARY_VERSION", rb_str_new2(OpenSSL_version(OPENSSL_VERSION)));
460
493
  #else
461
- rb_define_const(mod, "OPENSSL_LIBRARY_VERSION", rb_str_new2(SSLeay_version(SSLEAY_VERSION)));
494
+ rb_define_const(mod, "OPENSSL_LIBRARY_VERSION", rb_str_new2(SSLeay_version(SSLEAY_VERSION)));
462
495
  #endif
496
+
497
+ #if defined(OPENSSL_NO_SSL3) || defined(OPENSSL_NO_SSL3_METHOD)
498
+ /* True if SSL3 is not available */
499
+ rb_define_const(mod, "OPENSSL_NO_SSL3", Qtrue);
500
+ #else
501
+ rb_define_const(mod, "OPENSSL_NO_SSL3", Qfalse);
502
+ #endif
503
+
504
+ #if defined(OPENSSL_NO_TLS1) || defined(OPENSSL_NO_TLS1_METHOD)
505
+ /* True if TLS1 is not available */
506
+ rb_define_const(mod, "OPENSSL_NO_TLS1", Qtrue);
507
+ #else
508
+ rb_define_const(mod, "OPENSSL_NO_TLS1", Qfalse);
509
+ #endif
510
+
511
+ #if defined(OPENSSL_NO_TLS1_1) || defined(OPENSSL_NO_TLS1_1_METHOD)
512
+ /* True if TLS1_1 is not available */
513
+ rb_define_const(mod, "OPENSSL_NO_TLS1_1", Qtrue);
514
+ #else
515
+ rb_define_const(mod, "OPENSSL_NO_TLS1_1", Qfalse);
516
+ #endif
463
517
 
464
518
  rb_define_singleton_method(mod, "check", noop, 0);
465
519