piesync-puma 3.12.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (82) hide show
  1. checksums.yaml +7 -0
  2. data/History.md +1429 -0
  3. data/LICENSE +26 -0
  4. data/README.md +280 -0
  5. data/bin/puma +10 -0
  6. data/bin/puma-wild +31 -0
  7. data/bin/pumactl +12 -0
  8. data/docs/architecture.md +36 -0
  9. data/docs/deployment.md +91 -0
  10. data/docs/images/puma-connection-flow-no-reactor.png +0 -0
  11. data/docs/images/puma-connection-flow.png +0 -0
  12. data/docs/images/puma-general-arch.png +0 -0
  13. data/docs/nginx.md +80 -0
  14. data/docs/plugins.md +28 -0
  15. data/docs/restart.md +39 -0
  16. data/docs/signals.md +96 -0
  17. data/docs/systemd.md +272 -0
  18. data/ext/puma_http11/PumaHttp11Service.java +17 -0
  19. data/ext/puma_http11/ext_help.h +15 -0
  20. data/ext/puma_http11/extconf.rb +15 -0
  21. data/ext/puma_http11/http11_parser.c +1071 -0
  22. data/ext/puma_http11/http11_parser.h +65 -0
  23. data/ext/puma_http11/http11_parser.java.rl +161 -0
  24. data/ext/puma_http11/http11_parser.rl +149 -0
  25. data/ext/puma_http11/http11_parser_common.rl +54 -0
  26. data/ext/puma_http11/io_buffer.c +155 -0
  27. data/ext/puma_http11/mini_ssl.c +494 -0
  28. data/ext/puma_http11/org/jruby/puma/Http11.java +234 -0
  29. data/ext/puma_http11/org/jruby/puma/Http11Parser.java +470 -0
  30. data/ext/puma_http11/org/jruby/puma/MiniSSL.java +352 -0
  31. data/ext/puma_http11/puma_http11.c +500 -0
  32. data/lib/puma.rb +23 -0
  33. data/lib/puma/accept_nonblock.rb +23 -0
  34. data/lib/puma/app/status.rb +74 -0
  35. data/lib/puma/binder.rb +413 -0
  36. data/lib/puma/cli.rb +235 -0
  37. data/lib/puma/client.rb +480 -0
  38. data/lib/puma/cluster.rb +531 -0
  39. data/lib/puma/commonlogger.rb +108 -0
  40. data/lib/puma/compat.rb +14 -0
  41. data/lib/puma/configuration.rb +361 -0
  42. data/lib/puma/const.rb +239 -0
  43. data/lib/puma/control_cli.rb +264 -0
  44. data/lib/puma/convenient.rb +25 -0
  45. data/lib/puma/daemon_ext.rb +33 -0
  46. data/lib/puma/delegation.rb +13 -0
  47. data/lib/puma/detect.rb +15 -0
  48. data/lib/puma/dsl.rb +518 -0
  49. data/lib/puma/events.rb +153 -0
  50. data/lib/puma/io_buffer.rb +9 -0
  51. data/lib/puma/java_io_buffer.rb +47 -0
  52. data/lib/puma/jruby_restart.rb +84 -0
  53. data/lib/puma/launcher.rb +433 -0
  54. data/lib/puma/minissl.rb +285 -0
  55. data/lib/puma/null_io.rb +44 -0
  56. data/lib/puma/plugin.rb +117 -0
  57. data/lib/puma/plugin/tmp_restart.rb +34 -0
  58. data/lib/puma/rack/backports/uri/common_193.rb +33 -0
  59. data/lib/puma/rack/builder.rb +299 -0
  60. data/lib/puma/rack/urlmap.rb +91 -0
  61. data/lib/puma/rack_default.rb +7 -0
  62. data/lib/puma/reactor.rb +347 -0
  63. data/lib/puma/runner.rb +184 -0
  64. data/lib/puma/server.rb +1072 -0
  65. data/lib/puma/single.rb +123 -0
  66. data/lib/puma/state_file.rb +31 -0
  67. data/lib/puma/tcp_logger.rb +41 -0
  68. data/lib/puma/thread_pool.rb +346 -0
  69. data/lib/puma/util.rb +129 -0
  70. data/lib/rack/handler/puma.rb +115 -0
  71. data/tools/jungle/README.md +19 -0
  72. data/tools/jungle/init.d/README.md +61 -0
  73. data/tools/jungle/init.d/puma +421 -0
  74. data/tools/jungle/init.d/run-puma +18 -0
  75. data/tools/jungle/rc.d/README.md +74 -0
  76. data/tools/jungle/rc.d/puma +61 -0
  77. data/tools/jungle/rc.d/puma.conf +10 -0
  78. data/tools/jungle/upstart/README.md +61 -0
  79. data/tools/jungle/upstart/puma-manager.conf +31 -0
  80. data/tools/jungle/upstart/puma.conf +69 -0
  81. data/tools/trickletest.rb +45 -0
  82. metadata +131 -0
@@ -0,0 +1,494 @@
1
+ #define RSTRING_NOT_MODIFIED 1
2
+
3
+ #include <ruby.h>
4
+ #include <ruby/version.h>
5
+
6
+ #if RUBY_API_VERSION_MAJOR == 1
7
+ #include <rubyio.h>
8
+ #else
9
+ #include <ruby/io.h>
10
+ #endif
11
+
12
+ #ifdef HAVE_OPENSSL_BIO_H
13
+
14
+ #include <openssl/bio.h>
15
+ #include <openssl/ssl.h>
16
+ #include <openssl/dh.h>
17
+ #include <openssl/err.h>
18
+ #include <openssl/x509.h>
19
+
20
+ #ifndef SSL_OP_NO_COMPRESSION
21
+ #define SSL_OP_NO_COMPRESSION 0
22
+ #endif
23
+
24
+ typedef struct {
25
+ BIO* read;
26
+ BIO* write;
27
+ SSL* ssl;
28
+ SSL_CTX* ctx;
29
+ } ms_conn;
30
+
31
+ typedef struct {
32
+ unsigned char* buf;
33
+ int bytes;
34
+ } ms_cert_buf;
35
+
36
+ void engine_free(ms_conn* conn) {
37
+ ms_cert_buf* cert_buf = (ms_cert_buf*)SSL_get_app_data(conn->ssl);
38
+ if(cert_buf) {
39
+ OPENSSL_free(cert_buf->buf);
40
+ free(cert_buf);
41
+ }
42
+ SSL_free(conn->ssl);
43
+ SSL_CTX_free(conn->ctx);
44
+
45
+ free(conn);
46
+ }
47
+
48
+ ms_conn* engine_alloc(VALUE klass, VALUE* obj) {
49
+ ms_conn* conn;
50
+
51
+ *obj = Data_Make_Struct(klass, ms_conn, 0, engine_free, conn);
52
+
53
+ conn->read = BIO_new(BIO_s_mem());
54
+ BIO_set_nbio(conn->read, 1);
55
+
56
+ conn->write = BIO_new(BIO_s_mem());
57
+ BIO_set_nbio(conn->write, 1);
58
+
59
+ conn->ssl = 0;
60
+ conn->ctx = 0;
61
+
62
+ return conn;
63
+ }
64
+
65
+ DH *get_dh1024() {
66
+ /* `openssl dhparam 1024 -C`
67
+ * -----BEGIN DH PARAMETERS-----
68
+ * MIGHAoGBALPwcEv0OstmQCZdfHw0N5r+07lmXMxkpQacy1blwj0LUqC+Divp6pBk
69
+ * usTJ9W2/dOYr1X7zi6yXNLp4oLzc/31PUL3D9q8CpGS7vPz5gijKSw9BwCTT5z9+
70
+ * KF9v46qw8XqT5HHV87sWFlGQcVFq+pEkA2kPikkKZ/X/CCcpCAV7AgEC
71
+ * -----END DH PARAMETERS-----
72
+ */
73
+ static unsigned char dh1024_p[] = {
74
+ 0xB3,0xF0,0x70,0x4B,0xF4,0x3A,0xCB,0x66,0x40,0x26,0x5D,0x7C,
75
+ 0x7C,0x34,0x37,0x9A,0xFE,0xD3,0xB9,0x66,0x5C,0xCC,0x64,0xA5,
76
+ 0x06,0x9C,0xCB,0x56,0xE5,0xC2,0x3D,0x0B,0x52,0xA0,0xBE,0x0E,
77
+ 0x2B,0xE9,0xEA,0x90,0x64,0xBA,0xC4,0xC9,0xF5,0x6D,0xBF,0x74,
78
+ 0xE6,0x2B,0xD5,0x7E,0xF3,0x8B,0xAC,0x97,0x34,0xBA,0x78,0xA0,
79
+ 0xBC,0xDC,0xFF,0x7D,0x4F,0x50,0xBD,0xC3,0xF6,0xAF,0x02,0xA4,
80
+ 0x64,0xBB,0xBC,0xFC,0xF9,0x82,0x28,0xCA,0x4B,0x0F,0x41,0xC0,
81
+ 0x24,0xD3,0xE7,0x3F,0x7E,0x28,0x5F,0x6F,0xE3,0xAA,0xB0,0xF1,
82
+ 0x7A,0x93,0xE4,0x71,0xD5,0xF3,0xBB,0x16,0x16,0x51,0x90,0x71,
83
+ 0x51,0x6A,0xFA,0x91,0x24,0x03,0x69,0x0F,0x8A,0x49,0x0A,0x67,
84
+ 0xF5,0xFF,0x08,0x27,0x29,0x08,0x05,0x7B
85
+ };
86
+ static unsigned char dh1024_g[] = { 0x02 };
87
+
88
+ DH *dh;
89
+ dh = DH_new();
90
+
91
+ #if OPENSSL_VERSION_NUMBER < 0x10100005L || defined(LIBRESSL_VERSION_NUMBER)
92
+ dh->p = BN_bin2bn(dh1024_p, sizeof(dh1024_p), NULL);
93
+ dh->g = BN_bin2bn(dh1024_g, sizeof(dh1024_g), NULL);
94
+
95
+ if ((dh->p == NULL) || (dh->g == NULL)) {
96
+ DH_free(dh);
97
+ return NULL;
98
+ }
99
+ #else
100
+ BIGNUM *p, *g;
101
+ p = BN_bin2bn(dh1024_p, sizeof(dh1024_p), NULL);
102
+ g = BN_bin2bn(dh1024_g, sizeof(dh1024_g), NULL);
103
+
104
+ if (p == NULL || g == NULL || !DH_set0_pqg(dh, p, NULL, g)) {
105
+ DH_free(dh);
106
+ BN_free(p);
107
+ BN_free(g);
108
+ return NULL;
109
+ }
110
+ #endif
111
+
112
+ return dh;
113
+ }
114
+
115
+ static int engine_verify_callback(int preverify_ok, X509_STORE_CTX* ctx) {
116
+ X509* err_cert;
117
+ SSL* ssl;
118
+ int bytes;
119
+ unsigned char* buf = NULL;
120
+
121
+ if(!preverify_ok) {
122
+ err_cert = X509_STORE_CTX_get_current_cert(ctx);
123
+ if(err_cert) {
124
+ /*
125
+ * Save the failed certificate for inspection/logging.
126
+ */
127
+ bytes = i2d_X509(err_cert, &buf);
128
+ if(bytes > 0) {
129
+ ms_cert_buf* cert_buf = (ms_cert_buf*)malloc(sizeof(ms_cert_buf));
130
+ cert_buf->buf = buf;
131
+ cert_buf->bytes = bytes;
132
+ ssl = X509_STORE_CTX_get_ex_data(ctx, SSL_get_ex_data_X509_STORE_CTX_idx());
133
+ SSL_set_app_data(ssl, cert_buf);
134
+ }
135
+ }
136
+ }
137
+
138
+ return preverify_ok;
139
+ }
140
+
141
+ VALUE engine_init_server(VALUE self, VALUE mini_ssl_ctx) {
142
+ VALUE obj;
143
+ SSL_CTX* ctx;
144
+ SSL* ssl;
145
+
146
+ ms_conn* conn = engine_alloc(self, &obj);
147
+
148
+ ID sym_key = rb_intern("key");
149
+ VALUE key = rb_funcall(mini_ssl_ctx, sym_key, 0);
150
+
151
+ StringValue(key);
152
+
153
+ ID sym_cert = rb_intern("cert");
154
+ VALUE cert = rb_funcall(mini_ssl_ctx, sym_cert, 0);
155
+
156
+ StringValue(cert);
157
+
158
+ ID sym_ca = rb_intern("ca");
159
+ VALUE ca = rb_funcall(mini_ssl_ctx, sym_ca, 0);
160
+
161
+ ID sym_verify_mode = rb_intern("verify_mode");
162
+ VALUE verify_mode = rb_funcall(mini_ssl_ctx, sym_verify_mode, 0);
163
+
164
+ ID sym_ssl_cipher_filter = rb_intern("ssl_cipher_filter");
165
+ VALUE ssl_cipher_filter = rb_funcall(mini_ssl_ctx, sym_ssl_cipher_filter, 0);
166
+
167
+ ctx = SSL_CTX_new(SSLv23_server_method());
168
+ conn->ctx = ctx;
169
+
170
+ SSL_CTX_use_certificate_chain_file(ctx, RSTRING_PTR(cert));
171
+ SSL_CTX_use_PrivateKey_file(ctx, RSTRING_PTR(key), SSL_FILETYPE_PEM);
172
+
173
+ ID sym_verification_flags = rb_intern("verification_flags");
174
+ VALUE verification_flags = rb_funcall(mini_ssl_ctx, sym_verification_flags, 0);
175
+
176
+ if (!NIL_P(verification_flags)) {
177
+ X509_VERIFY_PARAM *param;
178
+ param = X509_VERIFY_PARAM_new();
179
+ X509_VERIFY_PARAM_set_flags(param, NUM2INT(verification_flags));
180
+ SSL_CTX_set1_param(ctx, param);
181
+ X509_VERIFY_PARAM_free(param);
182
+ }
183
+
184
+ if (!NIL_P(ca)) {
185
+ StringValue(ca);
186
+ SSL_CTX_load_verify_locations(ctx, RSTRING_PTR(ca), NULL);
187
+ }
188
+
189
+ SSL_CTX_set_options(ctx, 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);
190
+ SSL_CTX_set_session_cache_mode(ctx, SSL_SESS_CACHE_OFF);
191
+
192
+ if (!NIL_P(ssl_cipher_filter)) {
193
+ StringValue(ssl_cipher_filter);
194
+ SSL_CTX_set_cipher_list(ctx, RSTRING_PTR(ssl_cipher_filter));
195
+ }
196
+ else {
197
+ SSL_CTX_set_cipher_list(ctx, "HIGH:!aNULL@STRENGTH");
198
+ }
199
+
200
+ DH *dh = get_dh1024();
201
+ SSL_CTX_set_tmp_dh(ctx, dh);
202
+
203
+ #ifndef OPENSSL_NO_ECDH
204
+ EC_KEY *ecdh = EC_KEY_new_by_curve_name(NID_secp521r1);
205
+ if (ecdh) {
206
+ SSL_CTX_set_tmp_ecdh(ctx, ecdh);
207
+ EC_KEY_free(ecdh);
208
+ }
209
+ #endif
210
+
211
+ ssl = SSL_new(ctx);
212
+ conn->ssl = ssl;
213
+ SSL_set_app_data(ssl, NULL);
214
+
215
+ if (NIL_P(verify_mode)) {
216
+ /* SSL_set_verify(ssl, SSL_VERIFY_NONE, NULL); */
217
+ } else {
218
+ SSL_set_verify(ssl, NUM2INT(verify_mode), engine_verify_callback);
219
+ }
220
+
221
+ SSL_set_bio(ssl, conn->read, conn->write);
222
+
223
+ SSL_set_accept_state(ssl);
224
+ return obj;
225
+ }
226
+
227
+ VALUE engine_init_client(VALUE klass) {
228
+ VALUE obj;
229
+ ms_conn* conn = engine_alloc(klass, &obj);
230
+
231
+ conn->ctx = SSL_CTX_new(DTLSv1_method());
232
+ conn->ssl = SSL_new(conn->ctx);
233
+ SSL_set_app_data(conn->ssl, NULL);
234
+ SSL_set_verify(conn->ssl, SSL_VERIFY_NONE, NULL);
235
+
236
+ SSL_set_bio(conn->ssl, conn->read, conn->write);
237
+
238
+ SSL_set_connect_state(conn->ssl);
239
+ return obj;
240
+ }
241
+
242
+ VALUE engine_inject(VALUE self, VALUE str) {
243
+ ms_conn* conn;
244
+ long used;
245
+
246
+ Data_Get_Struct(self, ms_conn, conn);
247
+
248
+ StringValue(str);
249
+
250
+ used = BIO_write(conn->read, RSTRING_PTR(str), (int)RSTRING_LEN(str));
251
+
252
+ if(used == 0 || used == -1) {
253
+ return Qfalse;
254
+ }
255
+
256
+ return INT2FIX(used);
257
+ }
258
+
259
+ static VALUE eError;
260
+
261
+ void raise_error(SSL* ssl, int result) {
262
+ char buf[512];
263
+ char msg[512];
264
+ const char* err_str;
265
+ int err = errno;
266
+ int ssl_err = SSL_get_error(ssl, result);
267
+ int verify_err = (int) SSL_get_verify_result(ssl);
268
+
269
+ if(SSL_ERROR_SYSCALL == ssl_err) {
270
+ snprintf(msg, sizeof(msg), "System error: %s - %d", strerror(err), err);
271
+
272
+ } else if(SSL_ERROR_SSL == ssl_err) {
273
+ if(X509_V_OK != verify_err) {
274
+ err_str = X509_verify_cert_error_string(verify_err);
275
+ snprintf(msg, sizeof(msg),
276
+ "OpenSSL certificate verification error: %s - %d",
277
+ err_str, verify_err);
278
+
279
+ } else {
280
+ err = (int) ERR_get_error();
281
+ ERR_error_string_n(err, buf, sizeof(buf));
282
+ snprintf(msg, sizeof(msg), "OpenSSL error: %s - %d", buf, err);
283
+
284
+ }
285
+ } else {
286
+ snprintf(msg, sizeof(msg), "Unknown OpenSSL error: %d", ssl_err);
287
+ }
288
+
289
+ ERR_clear_error();
290
+ rb_raise(eError, "%s", msg);
291
+ }
292
+
293
+ VALUE engine_read(VALUE self) {
294
+ ms_conn* conn;
295
+ char buf[512];
296
+ int bytes, error;
297
+
298
+ Data_Get_Struct(self, ms_conn, conn);
299
+
300
+ ERR_clear_error();
301
+
302
+ bytes = SSL_read(conn->ssl, (void*)buf, sizeof(buf));
303
+
304
+ if(bytes > 0) {
305
+ return rb_str_new(buf, bytes);
306
+ }
307
+
308
+ if(SSL_want_read(conn->ssl)) return Qnil;
309
+
310
+ error = SSL_get_error(conn->ssl, bytes);
311
+
312
+ if(error == SSL_ERROR_ZERO_RETURN) {
313
+ rb_eof_error();
314
+ } else {
315
+ raise_error(conn->ssl, bytes);
316
+ }
317
+
318
+ return Qnil;
319
+ }
320
+
321
+ VALUE engine_write(VALUE self, VALUE str) {
322
+ ms_conn* conn;
323
+ int bytes;
324
+
325
+ Data_Get_Struct(self, ms_conn, conn);
326
+
327
+ StringValue(str);
328
+
329
+ ERR_clear_error();
330
+
331
+ bytes = SSL_write(conn->ssl, (void*)RSTRING_PTR(str), (int)RSTRING_LEN(str));
332
+ if(bytes > 0) {
333
+ return INT2FIX(bytes);
334
+ }
335
+
336
+ if(SSL_want_write(conn->ssl)) return Qnil;
337
+
338
+ raise_error(conn->ssl, bytes);
339
+
340
+ return Qnil;
341
+ }
342
+
343
+ VALUE engine_extract(VALUE self) {
344
+ ms_conn* conn;
345
+ int bytes;
346
+ size_t pending;
347
+ char buf[512];
348
+
349
+ Data_Get_Struct(self, ms_conn, conn);
350
+
351
+ pending = BIO_pending(conn->write);
352
+ if(pending > 0) {
353
+ bytes = BIO_read(conn->write, buf, sizeof(buf));
354
+ if(bytes > 0) {
355
+ return rb_str_new(buf, bytes);
356
+ } else if(!BIO_should_retry(conn->write)) {
357
+ raise_error(conn->ssl, bytes);
358
+ }
359
+ }
360
+
361
+ return Qnil;
362
+ }
363
+
364
+ VALUE engine_shutdown(VALUE self) {
365
+ ms_conn* conn;
366
+ int ok;
367
+
368
+ Data_Get_Struct(self, ms_conn, conn);
369
+
370
+ ERR_clear_error();
371
+
372
+ ok = SSL_shutdown(conn->ssl);
373
+ if (ok == 0) {
374
+ return Qfalse;
375
+ }
376
+
377
+ return Qtrue;
378
+ }
379
+
380
+ VALUE engine_init(VALUE self) {
381
+ ms_conn* conn;
382
+
383
+ Data_Get_Struct(self, ms_conn, conn);
384
+
385
+ return SSL_in_init(conn->ssl) ? Qtrue : Qfalse;
386
+ }
387
+
388
+ VALUE engine_peercert(VALUE self) {
389
+ ms_conn* conn;
390
+ X509* cert;
391
+ int bytes;
392
+ unsigned char* buf = NULL;
393
+ ms_cert_buf* cert_buf = NULL;
394
+ VALUE rb_cert_buf;
395
+
396
+ Data_Get_Struct(self, ms_conn, conn);
397
+
398
+ cert = SSL_get_peer_certificate(conn->ssl);
399
+ if(!cert) {
400
+ /*
401
+ * See if there was a failed certificate associated with this client.
402
+ */
403
+ cert_buf = (ms_cert_buf*)SSL_get_app_data(conn->ssl);
404
+ if(!cert_buf) {
405
+ return Qnil;
406
+ }
407
+ buf = cert_buf->buf;
408
+ bytes = cert_buf->bytes;
409
+
410
+ } else {
411
+ bytes = i2d_X509(cert, &buf);
412
+ X509_free(cert);
413
+
414
+ if(bytes < 0) {
415
+ return Qnil;
416
+ }
417
+ }
418
+
419
+ rb_cert_buf = rb_str_new((const char*)(buf), bytes);
420
+ if(!cert_buf) {
421
+ OPENSSL_free(buf);
422
+ }
423
+
424
+ return rb_cert_buf;
425
+ }
426
+
427
+ VALUE noop(VALUE self) {
428
+ return Qnil;
429
+ }
430
+
431
+ void Init_mini_ssl(VALUE puma) {
432
+ VALUE mod, eng;
433
+
434
+ /* Fake operation for documentation (RDoc, YARD) */
435
+ #if 0 == 1
436
+ puma = rb_define_module("Puma");
437
+ #endif
438
+
439
+ SSL_library_init();
440
+ OpenSSL_add_ssl_algorithms();
441
+ SSL_load_error_strings();
442
+ ERR_load_crypto_strings();
443
+
444
+ mod = rb_define_module_under(puma, "MiniSSL");
445
+ eng = rb_define_class_under(mod, "Engine", rb_cObject);
446
+
447
+ // OpenSSL Build / Runtime/Load versions
448
+
449
+ /* Version of OpenSSL that Puma was compiled with */
450
+ rb_define_const(mod, "OPENSSL_VERSION", rb_str_new2(OPENSSL_VERSION_TEXT));
451
+
452
+ #if !defined(LIBRESSL_VERSION_NUMBER) && OPENSSL_VERSION_NUMBER >= 0x10100000
453
+ /* Version of OpenSSL that Puma loaded with */
454
+ rb_define_const(mod, "OPENSSL_LIBRARY_VERSION", rb_str_new2(OpenSSL_version(OPENSSL_VERSION)));
455
+ #else
456
+ rb_define_const(mod, "OPENSSL_LIBRARY_VERSION", rb_str_new2(SSLeay_version(SSLEAY_VERSION)));
457
+ #endif
458
+
459
+ rb_define_singleton_method(mod, "check", noop, 0);
460
+
461
+ eError = rb_define_class_under(mod, "SSLError", rb_eStandardError);
462
+
463
+ rb_define_singleton_method(eng, "server", engine_init_server, 1);
464
+ rb_define_singleton_method(eng, "client", engine_init_client, 0);
465
+
466
+ rb_define_method(eng, "inject", engine_inject, 1);
467
+ rb_define_method(eng, "read", engine_read, 0);
468
+
469
+ rb_define_method(eng, "write", engine_write, 1);
470
+ rb_define_method(eng, "extract", engine_extract, 0);
471
+
472
+ rb_define_method(eng, "shutdown", engine_shutdown, 0);
473
+
474
+ rb_define_method(eng, "init?", engine_init, 0);
475
+
476
+ rb_define_method(eng, "peercert", engine_peercert, 0);
477
+ }
478
+
479
+ #else
480
+
481
+ VALUE raise_error(VALUE self) {
482
+ rb_raise(rb_eStandardError, "SSL not available in this build");
483
+ return Qnil;
484
+ }
485
+
486
+ void Init_mini_ssl(VALUE puma) {
487
+ VALUE mod;
488
+
489
+ mod = rb_define_module_under(puma, "MiniSSL");
490
+ rb_define_class_under(mod, "SSLError", rb_eStandardError);
491
+
492
+ rb_define_singleton_method(mod, "check", raise_error, 0);
493
+ }
494
+ #endif