openssl 2.1.2 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (60) hide show
  1. checksums.yaml +4 -4
  2. data/CONTRIBUTING.md +35 -45
  3. data/History.md +232 -0
  4. data/README.md +2 -2
  5. data/ext/openssl/extconf.rb +61 -46
  6. data/ext/openssl/openssl_missing.c +0 -66
  7. data/ext/openssl/openssl_missing.h +60 -44
  8. data/ext/openssl/ossl.c +112 -66
  9. data/ext/openssl/ossl.h +28 -11
  10. data/ext/openssl/ossl_asn1.c +42 -5
  11. data/ext/openssl/ossl_bn.c +276 -146
  12. data/ext/openssl/ossl_bn.h +2 -1
  13. data/ext/openssl/ossl_cipher.c +38 -29
  14. data/ext/openssl/ossl_config.c +412 -41
  15. data/ext/openssl/ossl_config.h +4 -7
  16. data/ext/openssl/ossl_digest.c +31 -62
  17. data/ext/openssl/ossl_engine.c +18 -27
  18. data/ext/openssl/ossl_hmac.c +52 -145
  19. data/ext/openssl/ossl_kdf.c +11 -19
  20. data/ext/openssl/ossl_ns_spki.c +1 -1
  21. data/ext/openssl/ossl_ocsp.c +9 -62
  22. data/ext/openssl/ossl_ocsp.h +3 -3
  23. data/ext/openssl/ossl_pkcs12.c +21 -3
  24. data/ext/openssl/ossl_pkcs7.c +45 -78
  25. data/ext/openssl/ossl_pkcs7.h +16 -0
  26. data/ext/openssl/ossl_pkey.c +1255 -178
  27. data/ext/openssl/ossl_pkey.h +40 -77
  28. data/ext/openssl/ossl_pkey_dh.c +125 -335
  29. data/ext/openssl/ossl_pkey_dsa.c +93 -398
  30. data/ext/openssl/ossl_pkey_ec.c +155 -318
  31. data/ext/openssl/ossl_pkey_rsa.c +105 -484
  32. data/ext/openssl/ossl_rand.c +2 -40
  33. data/ext/openssl/ossl_ssl.c +395 -364
  34. data/ext/openssl/ossl_ssl_session.c +24 -29
  35. data/ext/openssl/ossl_ts.c +1539 -0
  36. data/ext/openssl/ossl_ts.h +16 -0
  37. data/ext/openssl/ossl_x509.c +86 -1
  38. data/ext/openssl/ossl_x509cert.c +166 -10
  39. data/ext/openssl/ossl_x509crl.c +10 -7
  40. data/ext/openssl/ossl_x509ext.c +15 -2
  41. data/ext/openssl/ossl_x509name.c +16 -5
  42. data/ext/openssl/ossl_x509req.c +10 -7
  43. data/ext/openssl/ossl_x509store.c +193 -92
  44. data/lib/openssl/bn.rb +1 -1
  45. data/lib/openssl/buffering.rb +42 -17
  46. data/lib/openssl/cipher.rb +1 -1
  47. data/lib/openssl/digest.rb +10 -12
  48. data/lib/openssl/hmac.rb +78 -0
  49. data/lib/openssl/marshal.rb +30 -0
  50. data/lib/openssl/pkcs5.rb +1 -1
  51. data/lib/openssl/pkey.rb +435 -1
  52. data/lib/openssl/ssl.rb +53 -14
  53. data/lib/openssl/version.rb +5 -0
  54. data/lib/openssl/x509.rb +177 -1
  55. data/lib/openssl.rb +24 -9
  56. metadata +13 -69
  57. data/ext/openssl/deprecation.rb +0 -23
  58. data/ext/openssl/ossl_version.h +0 -15
  59. data/ext/openssl/ruby_missing.h +0 -24
  60. data/lib/openssl/config.rb +0 -474
@@ -52,8 +52,15 @@ struct ossl_verify_cb_args {
52
52
  };
53
53
 
54
54
  static VALUE
55
- call_verify_cb_proc(struct ossl_verify_cb_args *args)
55
+ ossl_x509stctx_new_i(VALUE arg)
56
56
  {
57
+ return ossl_x509stctx_new((X509_STORE_CTX *)arg);
58
+ }
59
+
60
+ static VALUE
61
+ call_verify_cb_proc(VALUE arg)
62
+ {
63
+ struct ossl_verify_cb_args *args = (struct ossl_verify_cb_args *)arg;
57
64
  return rb_funcall(args->proc, rb_intern("call"), 2,
58
65
  args->preverify_ok, args->store_ctx);
59
66
  }
@@ -69,7 +76,7 @@ ossl_verify_cb_call(VALUE proc, int ok, X509_STORE_CTX *ctx)
69
76
  return ok;
70
77
 
71
78
  ret = Qfalse;
72
- rctx = rb_protect((VALUE(*)(VALUE))ossl_x509stctx_new, (VALUE)ctx, &state);
79
+ rctx = rb_protect(ossl_x509stctx_new_i, (VALUE)ctx, &state);
73
80
  if (state) {
74
81
  rb_set_errinfo(Qnil);
75
82
  rb_warn("StoreContext initialization failure");
@@ -78,7 +85,7 @@ ossl_verify_cb_call(VALUE proc, int ok, X509_STORE_CTX *ctx)
78
85
  args.proc = proc;
79
86
  args.preverify_ok = ok ? Qtrue : Qfalse;
80
87
  args.store_ctx = rctx;
81
- ret = rb_protect((VALUE(*)(VALUE))call_verify_cb_proc, (VALUE)&args, &state);
88
+ ret = rb_protect(call_verify_cb_proc, (VALUE)&args, &state);
82
89
  if (state) {
83
90
  rb_set_errinfo(Qnil);
84
91
  rb_warn("exception in verify_callback is ignored");
@@ -105,6 +112,13 @@ VALUE cX509Store;
105
112
  VALUE cX509StoreContext;
106
113
  VALUE eX509StoreError;
107
114
 
115
+ static void
116
+ ossl_x509store_mark(void *ptr)
117
+ {
118
+ X509_STORE *store = ptr;
119
+ rb_gc_mark((VALUE)X509_STORE_get_ex_data(store, store_ex_verify_cb_idx));
120
+ }
121
+
108
122
  static void
109
123
  ossl_x509store_free(void *ptr)
110
124
  {
@@ -114,7 +128,7 @@ ossl_x509store_free(void *ptr)
114
128
  static const rb_data_type_t ossl_x509store_type = {
115
129
  "OpenSSL/X509/STORE",
116
130
  {
117
- 0, ossl_x509store_free,
131
+ ossl_x509store_mark, ossl_x509store_free,
118
132
  },
119
133
  0, 0, RUBY_TYPED_FREE_IMMEDIATELY,
120
134
  };
@@ -157,9 +171,8 @@ ossl_x509store_alloc(VALUE klass)
157
171
  VALUE obj;
158
172
 
159
173
  obj = NewX509Store(klass);
160
- if((store = X509_STORE_new()) == NULL){
161
- ossl_raise(eX509StoreError, NULL);
162
- }
174
+ if ((store = X509_STORE_new()) == NULL)
175
+ ossl_raise(eX509StoreError, "X509_STORE_new");
163
176
  SetX509Store(obj, store);
164
177
 
165
178
  return obj;
@@ -192,8 +205,9 @@ ossl_x509store_initialize(int argc, VALUE *argv, VALUE self)
192
205
  {
193
206
  X509_STORE *store;
194
207
 
195
- /* BUG: This method takes any number of arguments but appears to ignore them. */
196
208
  GetX509Store(self, store);
209
+ if (argc != 0)
210
+ rb_warn("OpenSSL::X509::Store.new does not take any arguments");
197
211
  #if !defined(HAVE_OPAQUE_OPENSSL)
198
212
  /* [Bug #405] [Bug #1678] [Bug #3000]; already fixed? */
199
213
  store->ex_data.sk = NULL;
@@ -214,8 +228,16 @@ ossl_x509store_initialize(int argc, VALUE *argv, VALUE self)
214
228
  * call-seq:
215
229
  * store.flags = flags
216
230
  *
217
- * Sets _flags_ to the Store. _flags_ consists of zero or more of the constants
218
- * defined in with name V_FLAG_* or'ed together.
231
+ * Sets the default flags used by certificate chain verification performed with
232
+ * the Store.
233
+ *
234
+ * _flags_ consists of zero or more of the constants defined in OpenSSL::X509
235
+ * with name V_FLAG_* or'ed together.
236
+ *
237
+ * OpenSSL::X509::StoreContext#flags= can be used to change the flags for a
238
+ * single verification operation.
239
+ *
240
+ * See also the man page X509_VERIFY_PARAM_set_flags(3).
219
241
  */
220
242
  static VALUE
221
243
  ossl_x509store_set_flags(VALUE self, VALUE flags)
@@ -233,9 +255,9 @@ ossl_x509store_set_flags(VALUE self, VALUE flags)
233
255
  * call-seq:
234
256
  * store.purpose = purpose
235
257
  *
236
- * Sets the store's purpose to _purpose_. If specified, the verifications on
237
- * the store will check every untrusted certificate's extensions are consistent
238
- * with the purpose. The purpose is specified by constants:
258
+ * Sets the store's default verification purpose. If specified,
259
+ * the verifications on the store will check every certificate's extensions are
260
+ * consistent with the purpose. The purpose is specified by constants:
239
261
  *
240
262
  * * X509::PURPOSE_SSL_CLIENT
241
263
  * * X509::PURPOSE_SSL_SERVER
@@ -246,6 +268,11 @@ ossl_x509store_set_flags(VALUE self, VALUE flags)
246
268
  * * X509::PURPOSE_ANY
247
269
  * * X509::PURPOSE_OCSP_HELPER
248
270
  * * X509::PURPOSE_TIMESTAMP_SIGN
271
+ *
272
+ * OpenSSL::X509::StoreContext#purpose= can be used to change the value for a
273
+ * single verification operation.
274
+ *
275
+ * See also the man page X509_VERIFY_PARAM_set_purpose(3).
249
276
  */
250
277
  static VALUE
251
278
  ossl_x509store_set_purpose(VALUE self, VALUE purpose)
@@ -262,6 +289,14 @@ ossl_x509store_set_purpose(VALUE self, VALUE purpose)
262
289
  /*
263
290
  * call-seq:
264
291
  * store.trust = trust
292
+ *
293
+ * Sets the default trust settings used by the certificate verification with
294
+ * the store.
295
+ *
296
+ * OpenSSL::X509::StoreContext#trust= can be used to change the value for a
297
+ * single verification operation.
298
+ *
299
+ * See also the man page X509_VERIFY_PARAM_set_trust(3).
265
300
  */
266
301
  static VALUE
267
302
  ossl_x509store_set_trust(VALUE self, VALUE trust)
@@ -279,7 +314,13 @@ ossl_x509store_set_trust(VALUE self, VALUE trust)
279
314
  * call-seq:
280
315
  * store.time = time
281
316
  *
282
- * Sets the time to be used in verifications.
317
+ * Sets the time to be used in the certificate verifications with the store.
318
+ * By default, if not specified, the current system time is used.
319
+ *
320
+ * OpenSSL::X509::StoreContext#time= can be used to change the value for a
321
+ * single verification operation.
322
+ *
323
+ * See also the man page X509_VERIFY_PARAM_set_time(3).
283
324
  */
284
325
  static VALUE
285
326
  ossl_x509store_set_time(VALUE self, VALUE time)
@@ -295,24 +336,23 @@ ossl_x509store_set_time(VALUE self, VALUE time)
295
336
  * Adds the certificates in _file_ to the certificate store. _file_ is the path
296
337
  * to the file, and the file contains one or more certificates in PEM format
297
338
  * concatenated together.
339
+ *
340
+ * See also the man page X509_LOOKUP_file(3).
298
341
  */
299
342
  static VALUE
300
343
  ossl_x509store_add_file(VALUE self, VALUE file)
301
344
  {
302
345
  X509_STORE *store;
303
346
  X509_LOOKUP *lookup;
304
- char *path = NULL;
347
+ const char *path;
305
348
 
306
- if(file != Qnil){
307
- rb_check_safe_obj(file);
308
- path = StringValueCStr(file);
309
- }
310
349
  GetX509Store(self, store);
350
+ path = StringValueCStr(file);
311
351
  lookup = X509_STORE_add_lookup(store, X509_LOOKUP_file());
312
- if(lookup == NULL) ossl_raise(eX509StoreError, NULL);
313
- if(X509_LOOKUP_load_file(lookup, path, X509_FILETYPE_PEM) != 1){
314
- ossl_raise(eX509StoreError, NULL);
315
- }
352
+ if (!lookup)
353
+ ossl_raise(eX509StoreError, "X509_STORE_add_lookup");
354
+ if (X509_LOOKUP_load_file(lookup, path, X509_FILETYPE_PEM) != 1)
355
+ ossl_raise(eX509StoreError, "X509_LOOKUP_load_file");
316
356
  #if OPENSSL_VERSION_NUMBER < 0x10101000 || defined(LIBRESSL_VERSION_NUMBER)
317
357
  /*
318
358
  * X509_load_cert_crl_file() which is called from X509_LOOKUP_load_file()
@@ -331,24 +371,23 @@ ossl_x509store_add_file(VALUE self, VALUE file)
331
371
  * store.add_path(path) -> self
332
372
  *
333
373
  * Adds _path_ as the hash dir to be looked up by the store.
374
+ *
375
+ * See also the man page X509_LOOKUP_hash_dir(3).
334
376
  */
335
377
  static VALUE
336
378
  ossl_x509store_add_path(VALUE self, VALUE dir)
337
379
  {
338
380
  X509_STORE *store;
339
381
  X509_LOOKUP *lookup;
340
- char *path = NULL;
382
+ const char *path;
341
383
 
342
- if(dir != Qnil){
343
- rb_check_safe_obj(dir);
344
- path = StringValueCStr(dir);
345
- }
346
384
  GetX509Store(self, store);
385
+ path = StringValueCStr(dir);
347
386
  lookup = X509_STORE_add_lookup(store, X509_LOOKUP_hash_dir());
348
- if(lookup == NULL) ossl_raise(eX509StoreError, NULL);
349
- if(X509_LOOKUP_add_dir(lookup, path, X509_FILETYPE_PEM) != 1){
350
- ossl_raise(eX509StoreError, NULL);
351
- }
387
+ if (!lookup)
388
+ ossl_raise(eX509StoreError, "X509_STORE_add_lookup");
389
+ if (X509_LOOKUP_add_dir(lookup, path, X509_FILETYPE_PEM) != 1)
390
+ ossl_raise(eX509StoreError, "X509_LOOKUP_add_dir");
352
391
 
353
392
  return self;
354
393
  }
@@ -363,6 +402,8 @@ ossl_x509store_add_path(VALUE self, VALUE dir)
363
402
  *
364
403
  * * OpenSSL::X509::DEFAULT_CERT_FILE
365
404
  * * OpenSSL::X509::DEFAULT_CERT_DIR
405
+ *
406
+ * See also the man page X509_STORE_set_default_paths(3).
366
407
  */
367
408
  static VALUE
368
409
  ossl_x509store_set_default_paths(VALUE self)
@@ -370,18 +411,19 @@ ossl_x509store_set_default_paths(VALUE self)
370
411
  X509_STORE *store;
371
412
 
372
413
  GetX509Store(self, store);
373
- if (X509_STORE_set_default_paths(store) != 1){
374
- ossl_raise(eX509StoreError, NULL);
375
- }
414
+ if (X509_STORE_set_default_paths(store) != 1)
415
+ ossl_raise(eX509StoreError, "X509_STORE_set_default_paths");
376
416
 
377
417
  return Qnil;
378
418
  }
379
419
 
380
420
  /*
381
421
  * call-seq:
382
- * store.add_cert(cert)
422
+ * store.add_cert(cert) -> self
383
423
  *
384
424
  * Adds the OpenSSL::X509::Certificate _cert_ to the certificate store.
425
+ *
426
+ * See also the man page X509_STORE_add_cert(3).
385
427
  */
386
428
  static VALUE
387
429
  ossl_x509store_add_cert(VALUE self, VALUE arg)
@@ -391,9 +433,8 @@ ossl_x509store_add_cert(VALUE self, VALUE arg)
391
433
 
392
434
  cert = GetX509CertPtr(arg); /* NO NEED TO DUP */
393
435
  GetX509Store(self, store);
394
- if (X509_STORE_add_cert(store, cert) != 1){
395
- ossl_raise(eX509StoreError, NULL);
396
- }
436
+ if (X509_STORE_add_cert(store, cert) != 1)
437
+ ossl_raise(eX509StoreError, "X509_STORE_add_cert");
397
438
 
398
439
  return self;
399
440
  }
@@ -403,6 +444,8 @@ ossl_x509store_add_cert(VALUE self, VALUE arg)
403
444
  * store.add_crl(crl) -> self
404
445
  *
405
446
  * Adds the OpenSSL::X509::CRL _crl_ to the store.
447
+ *
448
+ * See also the man page X509_STORE_add_crl(3).
406
449
  */
407
450
  static VALUE
408
451
  ossl_x509store_add_crl(VALUE self, VALUE arg)
@@ -412,9 +455,8 @@ ossl_x509store_add_crl(VALUE self, VALUE arg)
412
455
 
413
456
  crl = GetX509CRLPtr(arg); /* NO NEED TO DUP */
414
457
  GetX509Store(self, store);
415
- if (X509_STORE_add_crl(store, crl) != 1){
416
- ossl_raise(eX509StoreError, NULL);
417
- }
458
+ if (X509_STORE_add_crl(store, crl) != 1)
459
+ ossl_raise(eX509StoreError, "X509_STORE_add_crl");
418
460
 
419
461
  return self;
420
462
  }
@@ -458,23 +500,16 @@ ossl_x509store_verify(int argc, VALUE *argv, VALUE self)
458
500
  return result;
459
501
  }
460
502
 
461
- /*
462
- * Public Functions
463
- */
464
- static void ossl_x509stctx_free(void*);
465
-
466
-
467
- static const rb_data_type_t ossl_x509stctx_type = {
468
- "OpenSSL/X509/STORE_CTX",
469
- {
470
- 0, ossl_x509stctx_free,
471
- },
472
- 0, 0, RUBY_TYPED_FREE_IMMEDIATELY,
473
- };
474
-
475
503
  /*
476
504
  * Private functions
477
505
  */
506
+ static void
507
+ ossl_x509stctx_mark(void *ptr)
508
+ {
509
+ X509_STORE_CTX *ctx = ptr;
510
+ rb_gc_mark((VALUE)X509_STORE_CTX_get_ex_data(ctx, stctx_ex_verify_cb_idx));
511
+ }
512
+
478
513
  static void
479
514
  ossl_x509stctx_free(void *ptr)
480
515
  {
@@ -486,6 +521,14 @@ ossl_x509stctx_free(void *ptr)
486
521
  X509_STORE_CTX_free(ctx);
487
522
  }
488
523
 
524
+ static const rb_data_type_t ossl_x509stctx_type = {
525
+ "OpenSSL/X509/STORE_CTX",
526
+ {
527
+ ossl_x509stctx_mark, ossl_x509stctx_free,
528
+ },
529
+ 0, 0, RUBY_TYPED_FREE_IMMEDIATELY,
530
+ };
531
+
489
532
  static VALUE
490
533
  ossl_x509stctx_alloc(VALUE klass)
491
534
  {
@@ -493,9 +536,8 @@ ossl_x509stctx_alloc(VALUE klass)
493
536
  VALUE obj;
494
537
 
495
538
  obj = NewX509StCtx(klass);
496
- if((ctx = X509_STORE_CTX_new()) == NULL){
497
- ossl_raise(eX509StoreError, NULL);
498
- }
539
+ if ((ctx = X509_STORE_CTX_new()) == NULL)
540
+ ossl_raise(eX509StoreError, "X509_STORE_CTX_new");
499
541
  SetX509StCtx(obj, ctx);
500
542
 
501
543
  return obj;
@@ -519,7 +561,9 @@ static VALUE ossl_x509stctx_set_time(VALUE, VALUE);
519
561
 
520
562
  /*
521
563
  * call-seq:
522
- * StoreContext.new(store, cert = nil, chain = nil)
564
+ * StoreContext.new(store, cert = nil, untrusted = nil)
565
+ *
566
+ * Sets up a StoreContext for a verification of the X.509 certificate _cert_.
523
567
  */
524
568
  static VALUE
525
569
  ossl_x509stctx_initialize(int argc, VALUE *argv, VALUE self)
@@ -529,15 +573,24 @@ ossl_x509stctx_initialize(int argc, VALUE *argv, VALUE self)
529
573
  X509_STORE *x509st;
530
574
  X509 *x509 = NULL;
531
575
  STACK_OF(X509) *x509s = NULL;
576
+ int state;
532
577
 
533
578
  rb_scan_args(argc, argv, "12", &store, &cert, &chain);
534
579
  GetX509StCtx(self, ctx);
535
580
  GetX509Store(store, x509st);
536
- if(!NIL_P(cert)) x509 = DupX509CertPtr(cert); /* NEED TO DUP */
537
- if(!NIL_P(chain)) x509s = ossl_x509_ary2sk(chain);
538
- if(X509_STORE_CTX_init(ctx, x509st, x509, x509s) != 1){
581
+ if (!NIL_P(cert))
582
+ x509 = DupX509CertPtr(cert); /* NEED TO DUP */
583
+ if (!NIL_P(chain)) {
584
+ x509s = ossl_protect_x509_ary2sk(chain, &state);
585
+ if (state) {
586
+ X509_free(x509);
587
+ rb_jump_tag(state);
588
+ }
589
+ }
590
+ if (X509_STORE_CTX_init(ctx, x509st, x509, x509s) != 1){
591
+ X509_free(x509);
539
592
  sk_X509_pop_free(x509s, X509_free);
540
- ossl_raise(eX509StoreError, NULL);
593
+ ossl_raise(eX509StoreError, "X509_STORE_CTX_init");
541
594
  }
542
595
  if (!NIL_P(t = rb_iv_get(store, "@time")))
543
596
  ossl_x509stctx_set_time(self, t);
@@ -550,6 +603,10 @@ ossl_x509stctx_initialize(int argc, VALUE *argv, VALUE self)
550
603
  /*
551
604
  * call-seq:
552
605
  * stctx.verify -> true | false
606
+ *
607
+ * Performs the certificate verification using the parameters set to _stctx_.
608
+ *
609
+ * See also the man page X509_verify_cert(3).
553
610
  */
554
611
  static VALUE
555
612
  ossl_x509stctx_verify(VALUE self)
@@ -562,48 +619,45 @@ ossl_x509stctx_verify(VALUE self)
562
619
 
563
620
  switch (X509_verify_cert(ctx)) {
564
621
  case 1:
565
- return Qtrue;
622
+ return Qtrue;
566
623
  case 0:
567
- ossl_clear_error();
568
- return Qfalse;
624
+ ossl_clear_error();
625
+ return Qfalse;
569
626
  default:
570
- ossl_raise(eX509CertError, NULL);
627
+ ossl_raise(eX509CertError, "X509_verify_cert");
571
628
  }
572
629
  }
573
630
 
574
631
  /*
575
632
  * call-seq:
576
- * stctx.chain -> Array of X509::Certificate
633
+ * stctx.chain -> nil | Array of X509::Certificate
634
+ *
635
+ * Returns the verified chain.
636
+ *
637
+ * See also the man page X509_STORE_CTX_set0_verified_chain(3).
577
638
  */
578
639
  static VALUE
579
640
  ossl_x509stctx_get_chain(VALUE self)
580
641
  {
581
642
  X509_STORE_CTX *ctx;
582
- STACK_OF(X509) *chain;
583
- X509 *x509;
584
- int i, num;
585
- VALUE ary;
643
+ const STACK_OF(X509) *chain;
586
644
 
587
645
  GetX509StCtx(self, ctx);
588
- if((chain = X509_STORE_CTX_get0_chain(ctx)) == NULL){
589
- return Qnil;
590
- }
591
- if((num = sk_X509_num(chain)) < 0){
592
- OSSL_Debug("certs in chain < 0???");
593
- return rb_ary_new();
594
- }
595
- ary = rb_ary_new2(num);
596
- for(i = 0; i < num; i++) {
597
- x509 = sk_X509_value(chain, i);
598
- rb_ary_push(ary, ossl_x509_new(x509));
599
- }
600
-
601
- return ary;
646
+ chain = X509_STORE_CTX_get0_chain(ctx);
647
+ if (!chain)
648
+ return Qnil; /* Could be an empty array instead? */
649
+ return ossl_x509_sk2ary(chain);
602
650
  }
603
651
 
604
652
  /*
605
653
  * call-seq:
606
654
  * stctx.error -> Integer
655
+ *
656
+ * Returns the error code of _stctx_. This is typically called after #verify
657
+ * is done, or from the verification callback set to
658
+ * OpenSSL::X509::Store#verify_callback=.
659
+ *
660
+ * See also the man page X509_STORE_CTX_get_error(3).
607
661
  */
608
662
  static VALUE
609
663
  ossl_x509stctx_get_err(VALUE self)
@@ -618,6 +672,11 @@ ossl_x509stctx_get_err(VALUE self)
618
672
  /*
619
673
  * call-seq:
620
674
  * stctx.error = error_code
675
+ *
676
+ * Sets the error code of _stctx_. This is used by the verification callback
677
+ * set to OpenSSL::X509::Store#verify_callback=.
678
+ *
679
+ * See also the man page X509_STORE_CTX_set_error(3).
621
680
  */
622
681
  static VALUE
623
682
  ossl_x509stctx_set_error(VALUE self, VALUE err)
@@ -634,7 +693,10 @@ ossl_x509stctx_set_error(VALUE self, VALUE err)
634
693
  * call-seq:
635
694
  * stctx.error_string -> String
636
695
  *
637
- * Returns the error string corresponding to the error code retrieved by #error.
696
+ * Returns the human readable error string corresponding to the error code
697
+ * retrieved by #error.
698
+ *
699
+ * See also the man page X509_verify_cert_error_string(3).
638
700
  */
639
701
  static VALUE
640
702
  ossl_x509stctx_get_err_string(VALUE self)
@@ -651,6 +713,10 @@ ossl_x509stctx_get_err_string(VALUE self)
651
713
  /*
652
714
  * call-seq:
653
715
  * stctx.error_depth -> Integer
716
+ *
717
+ * Returns the depth of the chain. This is used in combination with #error.
718
+ *
719
+ * See also the man page X509_STORE_CTX_get_error_depth(3).
654
720
  */
655
721
  static VALUE
656
722
  ossl_x509stctx_get_err_depth(VALUE self)
@@ -665,6 +731,10 @@ ossl_x509stctx_get_err_depth(VALUE self)
665
731
  /*
666
732
  * call-seq:
667
733
  * stctx.current_cert -> X509::Certificate
734
+ *
735
+ * Returns the certificate which caused the error.
736
+ *
737
+ * See also the man page X509_STORE_CTX_get_current_cert(3).
668
738
  */
669
739
  static VALUE
670
740
  ossl_x509stctx_get_curr_cert(VALUE self)
@@ -679,6 +749,10 @@ ossl_x509stctx_get_curr_cert(VALUE self)
679
749
  /*
680
750
  * call-seq:
681
751
  * stctx.current_crl -> X509::CRL
752
+ *
753
+ * Returns the CRL which caused the error.
754
+ *
755
+ * See also the man page X509_STORE_CTX_get_current_crl(3).
682
756
  */
683
757
  static VALUE
684
758
  ossl_x509stctx_get_curr_crl(VALUE self)
@@ -698,7 +772,10 @@ ossl_x509stctx_get_curr_crl(VALUE self)
698
772
  * call-seq:
699
773
  * stctx.flags = flags
700
774
  *
701
- * Sets the verification flags to the context. See Store#flags=.
775
+ * Sets the verification flags to the context. This overrides the default value
776
+ * set by Store#flags=.
777
+ *
778
+ * See also the man page X509_VERIFY_PARAM_set_flags(3).
702
779
  */
703
780
  static VALUE
704
781
  ossl_x509stctx_set_flags(VALUE self, VALUE flags)
@@ -716,7 +793,10 @@ ossl_x509stctx_set_flags(VALUE self, VALUE flags)
716
793
  * call-seq:
717
794
  * stctx.purpose = purpose
718
795
  *
719
- * Sets the purpose of the context. See Store#purpose=.
796
+ * Sets the purpose of the context. This overrides the default value set by
797
+ * Store#purpose=.
798
+ *
799
+ * See also the man page X509_VERIFY_PARAM_set_purpose(3).
720
800
  */
721
801
  static VALUE
722
802
  ossl_x509stctx_set_purpose(VALUE self, VALUE purpose)
@@ -733,6 +813,11 @@ ossl_x509stctx_set_purpose(VALUE self, VALUE purpose)
733
813
  /*
734
814
  * call-seq:
735
815
  * stctx.trust = trust
816
+ *
817
+ * Sets the trust settings of the context. This overrides the default value set
818
+ * by Store#trust=.
819
+ *
820
+ * See also the man page X509_VERIFY_PARAM_set_trust(3).
736
821
  */
737
822
  static VALUE
738
823
  ossl_x509stctx_set_trust(VALUE self, VALUE trust)
@@ -751,6 +836,8 @@ ossl_x509stctx_set_trust(VALUE self, VALUE trust)
751
836
  * stctx.time = time
752
837
  *
753
838
  * Sets the time used in the verification. If not set, the current time is used.
839
+ *
840
+ * See also the man page X509_VERIFY_PARAM_set_time(3).
754
841
  */
755
842
  static VALUE
756
843
  ossl_x509stctx_set_time(VALUE self, VALUE time)
@@ -826,23 +913,37 @@ Init_ossl_x509store(void)
826
913
  cX509Store = rb_define_class_under(mX509, "Store", rb_cObject);
827
914
  /*
828
915
  * The callback for additional certificate verification. It is invoked for
829
- * each untrusted certificate in the chain.
916
+ * each certificate in the chain and can be used to implement custom
917
+ * certificate verification conditions.
830
918
  *
831
919
  * The callback is invoked with two values, a boolean that indicates if the
832
920
  * pre-verification by OpenSSL has succeeded or not, and the StoreContext in
833
- * use. The callback must return either true or false.
921
+ * use.
922
+ *
923
+ * The callback can use StoreContext#error= to change the error code as
924
+ * needed. The callback must return either true or false.
925
+ *
926
+ * NOTE: any exception raised within the callback will be ignored.
927
+ *
928
+ * See also the man page X509_STORE_CTX_set_verify_cb(3).
834
929
  */
835
930
  rb_attr(cX509Store, rb_intern("verify_callback"), 1, 0, Qfalse);
836
931
  /*
837
932
  * The error code set by the last call of #verify.
933
+ *
934
+ * See also StoreContext#error.
838
935
  */
839
936
  rb_attr(cX509Store, rb_intern("error"), 1, 0, Qfalse);
840
937
  /*
841
938
  * The description for the error code set by the last call of #verify.
939
+ *
940
+ * See also StoreContext#error_string.
842
941
  */
843
942
  rb_attr(cX509Store, rb_intern("error_string"), 1, 0, Qfalse);
844
943
  /*
845
944
  * The certificate chain constructed by the last call of #verify.
945
+ *
946
+ * See also StoreContext#chain.
846
947
  */
847
948
  rb_attr(cX509Store, rb_intern("chain"), 1, 0, Qfalse);
848
949
  rb_define_alloc_func(cX509Store, ossl_x509store_alloc);
data/lib/openssl/bn.rb CHANGED
@@ -1,4 +1,4 @@
1
- # frozen_string_literal: false
1
+ # frozen_string_literal: true
2
2
  #--
3
3
  #
4
4
  # = Ruby-space definitions that completes C-space funcs for BN