summaryrefslogtreecommitdiffstats
path: root/OpenSSL/X509/Store.html
blob: e4d795b961a9479787945d8a1fc97651b7dec11c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
<!DOCTYPE html>

<html>
<head>
<meta charset="UTF-8">

<title>class OpenSSL::X509::Store - RDoc Documentation</title>

<script type="text/javascript">
  var rdoc_rel_prefix = "../../";
  var index_rel_prefix = "../../";
</script>

<script src="../../js/navigation.js" defer></script>
<script src="../../js/search.js" defer></script>
<script src="../../js/search_index.js" defer></script>
<script src="../../js/searcher.js" defer></script>
<script src="../../js/darkfish.js" defer></script>

<link href="../../css/fonts.css" rel="stylesheet">
<link href="../../css/rdoc.css" rel="stylesheet">


<body id="top" role="document" class="class">
<nav role="navigation">
  <div id="project-navigation">
    <div id="home-section" role="region" title="Quick navigation" class="nav-section">
  <h2>
    <a href="../../index.html" rel="home">Home</a>
  </h2>

  <div id="table-of-contents-navigation">
    <a href="../../table_of_contents.html#pages">Pages</a>
    <a href="../../table_of_contents.html#classes">Classes</a>
    <a href="../../table_of_contents.html#methods">Methods</a>
  </div>
</div>

    <div id="search-section" role="search" class="project-section initially-hidden">
  <form action="#" method="get" accept-charset="utf-8">
    <div id="search-field-wrapper">
      <input id="search-field" role="combobox" aria-label="Search"
             aria-autocomplete="list" aria-controls="search-results"
             type="text" name="search" placeholder="Search" spellcheck="false"
             title="Type to search, Up and Down to navigate, Enter to load">
    </div>

    <ul id="search-results" aria-label="Search Results"
        aria-busy="false" aria-expanded="false"
        aria-atomic="false" class="initially-hidden"></ul>
  </form>
</div>

  </div>

  

  <div id="class-metadata">
    
    
<div id="parent-class-section" class="nav-section">
  <h3>Parent</h3>

  <p class="link">Object
</div>

    
    
    
<!-- Method Quickref -->
<div id="method-list-section" class="nav-section">
  <h3>Methods</h3>

  <ul class="link-list" role="directory">
    <li ><a href="#method-c-new">::new</a>
    <li ><a href="#method-i-add_cert">#add_cert</a>
    <li ><a href="#method-i-add_crl">#add_crl</a>
    <li ><a href="#method-i-add_file">#add_file</a>
    <li ><a href="#method-i-add_path">#add_path</a>
    <li ><a href="#method-i-flags-3D">#flags=</a>
    <li ><a href="#method-i-purpose-3D">#purpose=</a>
    <li ><a href="#method-i-set_default_paths">#set_default_paths</a>
    <li ><a href="#method-i-time-3D">#time=</a>
    <li ><a href="#method-i-trust-3D">#trust=</a>
    <li ><a href="#method-i-verify">#verify</a>
    <li ><a href="#method-i-verify_callback-3D">#verify_callback=</a>
  </ul>
</div>

  </div>
</nav>

<main role="main" aria-labelledby="class-OpenSSL::X509::Store">
  <h1 id="class-OpenSSL::X509::Store" class="class">
    class OpenSSL::X509::Store
  </h1>

  <section class="description">
    
<p>The <a href="../X509.html"><code>X509</code></a> certificate store holds trusted CA certificates used to verify peer certificates.</p>

<p>The easiest way to create a useful certificate store is:</p>

<pre class="ruby"><span class="ruby-identifier">cert_store</span> = <span class="ruby-constant">OpenSSL</span><span class="ruby-operator">::</span><span class="ruby-constant">X509</span><span class="ruby-operator">::</span><span class="ruby-constant">Store</span>.<span class="ruby-identifier">new</span>
<span class="ruby-identifier">cert_store</span>.<span class="ruby-identifier">set_default_paths</span>
</pre>

<p>This will use your system’s built-in certificates.</p>

<p>If your system does not have a default set of certificates you can obtain a set extracted from Mozilla CA certificate store by cURL maintainers here: <a href="https://curl.haxx.se/docs/caextract.html">curl.haxx.se/docs/caextract.html</a> (You may wish to use the firefox-db2pem.sh script to extract the certificates from a local install to avoid man-in-the-middle attacks.)</p>

<p>After downloading or generating a cacert.pem from the above link you can create a certificate store from the pem file like this:</p>

<pre class="ruby"><span class="ruby-identifier">cert_store</span> = <span class="ruby-constant">OpenSSL</span><span class="ruby-operator">::</span><span class="ruby-constant">X509</span><span class="ruby-operator">::</span><span class="ruby-constant">Store</span>.<span class="ruby-identifier">new</span>
<span class="ruby-identifier">cert_store</span>.<span class="ruby-identifier">add_file</span> <span class="ruby-string">&#39;cacert.pem&#39;</span>
</pre>

<p>The certificate store can be used with an SSLSocket like this:</p>

<pre class="ruby"><span class="ruby-identifier">ssl_context</span> = <span class="ruby-constant">OpenSSL</span><span class="ruby-operator">::</span><span class="ruby-constant">SSL</span><span class="ruby-operator">::</span><span class="ruby-constant">SSLContext</span>.<span class="ruby-identifier">new</span>
<span class="ruby-identifier">ssl_context</span>.<span class="ruby-identifier">verify_mode</span> = <span class="ruby-constant">OpenSSL</span><span class="ruby-operator">::</span><span class="ruby-constant">SSL</span><span class="ruby-operator">::</span><span class="ruby-constant">VERIFY_PEER</span>
<span class="ruby-identifier">ssl_context</span>.<span class="ruby-identifier">cert_store</span> = <span class="ruby-identifier">cert_store</span>

<span class="ruby-identifier">tcp_socket</span> = <span class="ruby-constant">TCPSocket</span>.<span class="ruby-identifier">open</span> <span class="ruby-string">&#39;example.com&#39;</span>, <span class="ruby-value">443</span>

<span class="ruby-identifier">ssl_socket</span> = <span class="ruby-constant">OpenSSL</span><span class="ruby-operator">::</span><span class="ruby-constant">SSL</span><span class="ruby-operator">::</span><span class="ruby-constant">SSLSocket</span>.<span class="ruby-identifier">new</span> <span class="ruby-identifier">tcp_socket</span>, <span class="ruby-identifier">ssl_context</span>
</pre>

  </section>

  <section id="5Buntitled-5D" class="documentation-section">



    <section class="attribute-method-details" class="method-section">
      <header>
        <h3>Attributes</h3>
      </header>

      <div id="attribute-i-chain" class="method-detail">
        <div class="method-heading attribute-method-heading">
          <span class="method-name">chain</span><span
            class="attribute-access-type">[R]</span>
        </div>

        <div class="method-description">
        <p>The certificate chain constructed by the last call of <a href="Store.html#method-i-verify"><code>verify</code></a>.</p>

<p>See also <a href="StoreContext.html#method-i-chain"><code>StoreContext#chain</code></a>.</p>
        </div>
      </div>
      <div id="attribute-i-error" class="method-detail">
        <div class="method-heading attribute-method-heading">
          <span class="method-name">error</span><span
            class="attribute-access-type">[R]</span>
        </div>

        <div class="method-description">
        <p>The error code set by the last call of <a href="Store.html#method-i-verify"><code>verify</code></a>.</p>

<p>See also <a href="StoreContext.html#method-i-error"><code>StoreContext#error</code></a>.</p>
        </div>
      </div>
      <div id="attribute-i-error_string" class="method-detail">
        <div class="method-heading attribute-method-heading">
          <span class="method-name">error_string</span><span
            class="attribute-access-type">[R]</span>
        </div>

        <div class="method-description">
        <p>The description for the error code set by the last call of <a href="Store.html#method-i-verify"><code>verify</code></a>.</p>

<p>See also <a href="StoreContext.html#method-i-error_string"><code>StoreContext#error_string</code></a>.</p>
        </div>
      </div>
      <div id="attribute-i-verify_callback" class="method-detail">
        <div class="method-heading attribute-method-heading">
          <span class="method-name">verify_callback</span><span
            class="attribute-access-type">[R]</span>
        </div>

        <div class="method-description">
        <p>The callback for additional certificate verification. It is invoked for each certificate in the chain and can be used to implement custom certificate verification conditions.</p>

<p>The callback is invoked with two values, a boolean that indicates if the pre-verification by <a href="../../OpenSSL.html"><code>OpenSSL</code></a> has succeeded or not, and the <a href="StoreContext.html"><code>StoreContext</code></a> in use.</p>

<p>The callback can use <a href="StoreContext.html#method-i-error-3D"><code>StoreContext#error=</code></a> to change the error code as needed. The callback must return either true or false.</p>

<p>NOTE: any exception raised within the callback will be ignored.</p>

<p>See also the man page X509_STORE_CTX_set_verify_cb(3).</p>
        </div>
      </div>
    </section>


     <section id="public-class-5Buntitled-5D-method-details" class="method-section">
       <header>
         <h3>Public Class Methods</h3>
       </header>

      <div id="method-c-new" class="method-detail ">
        <div class="method-heading">
          <span class="method-callseq">
            X509::Store.new &rarr; store
          </span>
          <span class="method-click-advice">click to toggle source</span>
        </div>

        <div class="method-description">
          <p>Creates a new <a href="Store.html"><code>X509::Store</code></a>.</p>

          <div class="method-source-code" id="new-source">
            <pre>static VALUE
ossl_x509store_initialize(int argc, VALUE *argv, VALUE self)
{
    X509_STORE *store;

    GetX509Store(self, store);
    if (argc != 0)
        rb_warn(&quot;OpenSSL::X509::Store.new does not take any arguments&quot;);
#if !defined(HAVE_OPAQUE_OPENSSL)
    /* [Bug #405] [Bug #1678] [Bug #3000]; already fixed? */
    store-&gt;ex_data.sk = NULL;
#endif
    X509_STORE_set_verify_cb(store, x509store_verify_cb);
    ossl_x509store_set_vfy_cb(self, Qnil);

    /* last verification status */
    rb_iv_set(self, &quot;@error&quot;, Qnil);
    rb_iv_set(self, &quot;@error_string&quot;, Qnil);
    rb_iv_set(self, &quot;@chain&quot;, Qnil);
    rb_iv_set(self, &quot;@time&quot;, Qnil);

    return self;
}</pre>
          </div>
        </div>


      </div>

    </section>

     <section id="public-instance-5Buntitled-5D-method-details" class="method-section">
       <header>
         <h3>Public Instance Methods</h3>
       </header>

      <div id="method-i-add_cert" class="method-detail ">
        <div class="method-heading">
          <span class="method-callseq">
            add_cert(cert) &rarr; self
          </span>
          <span class="method-click-advice">click to toggle source</span>
        </div>

        <div class="method-description">
          <p>Adds the <a href="Certificate.html"><code>OpenSSL::X509::Certificate</code></a> <em>cert</em> to the certificate store.</p>

<p>See also the man page X509_STORE_add_cert(3).</p>

          <div class="method-source-code" id="add_cert-source">
            <pre>static VALUE
ossl_x509store_add_cert(VALUE self, VALUE arg)
{
    X509_STORE *store;
    X509 *cert;

    cert = GetX509CertPtr(arg); /* NO NEED TO DUP */
    GetX509Store(self, store);
    if (X509_STORE_add_cert(store, cert) != 1)
        ossl_raise(eX509StoreError, &quot;X509_STORE_add_cert&quot;);

    return self;
}</pre>
          </div>
        </div>


      </div>

      <div id="method-i-add_crl" class="method-detail ">
        <div class="method-heading">
          <span class="method-callseq">
            add_crl(crl) &rarr; self
          </span>
          <span class="method-click-advice">click to toggle source</span>
        </div>

        <div class="method-description">
          <p>Adds the <a href="CRL.html"><code>OpenSSL::X509::CRL</code></a> <em>crl</em> to the store.</p>

<p>See also the man page X509_STORE_add_crl(3).</p>

          <div class="method-source-code" id="add_crl-source">
            <pre>static VALUE
ossl_x509store_add_crl(VALUE self, VALUE arg)
{
    X509_STORE *store;
    X509_CRL *crl;

    crl = GetX509CRLPtr(arg); /* NO NEED TO DUP */
    GetX509Store(self, store);
    if (X509_STORE_add_crl(store, crl) != 1)
        ossl_raise(eX509StoreError, &quot;X509_STORE_add_crl&quot;);

    return self;
}</pre>
          </div>
        </div>


      </div>

      <div id="method-i-add_file" class="method-detail ">
        <div class="method-heading">
          <span class="method-callseq">
            add_file(file) &rarr; self
          </span>
          <span class="method-click-advice">click to toggle source</span>
        </div>

        <div class="method-description">
          <p>Adds the certificates in <em>file</em> to the certificate store. <em>file</em> is the path to the file, and the file contains one or more certificates in PEM format concatenated together.</p>

<p>See also the man page X509_LOOKUP_file(3).</p>

          <div class="method-source-code" id="add_file-source">
            <pre>static VALUE
ossl_x509store_add_file(VALUE self, VALUE file)
{
    X509_STORE *store;
    X509_LOOKUP *lookup;
    const char *path;

    GetX509Store(self, store);
    path = StringValueCStr(file);
    lookup = X509_STORE_add_lookup(store, X509_LOOKUP_file());
    if (!lookup)
        ossl_raise(eX509StoreError, &quot;X509_STORE_add_lookup&quot;);
    if (X509_LOOKUP_load_file(lookup, path, X509_FILETYPE_PEM) != 1)
        ossl_raise(eX509StoreError, &quot;X509_LOOKUP_load_file&quot;);
#if OPENSSL_VERSION_NUMBER &lt; 0x10101000 || defined(LIBRESSL_VERSION_NUMBER)
    /*
     * X509_load_cert_crl_file() which is called from X509_LOOKUP_load_file()
     * did not check the return value of X509_STORE_add_{cert,crl}(), leaking
     * &quot;cert already in hash table&quot; errors on the error queue, if duplicate
     * certificates are found. This will be fixed by OpenSSL 1.1.1.
     */
    ossl_clear_error();
#endif

    return self;
}</pre>
          </div>
        </div>


      </div>

      <div id="method-i-add_path" class="method-detail ">
        <div class="method-heading">
          <span class="method-callseq">
            add_path(path) &rarr; self
          </span>
          <span class="method-click-advice">click to toggle source</span>
        </div>

        <div class="method-description">
          <p>Adds <em>path</em> as the hash dir to be looked up by the store.</p>

<p>See also the man page X509_LOOKUP_hash_dir(3).</p>

          <div class="method-source-code" id="add_path-source">
            <pre>static VALUE
ossl_x509store_add_path(VALUE self, VALUE dir)
{
    X509_STORE *store;
    X509_LOOKUP *lookup;
    const char *path;

    GetX509Store(self, store);
    path = StringValueCStr(dir);
    lookup = X509_STORE_add_lookup(store, X509_LOOKUP_hash_dir());
    if (!lookup)
        ossl_raise(eX509StoreError, &quot;X509_STORE_add_lookup&quot;);
    if (X509_LOOKUP_add_dir(lookup, path, X509_FILETYPE_PEM) != 1)
        ossl_raise(eX509StoreError, &quot;X509_LOOKUP_add_dir&quot;);

    return self;
}</pre>
          </div>
        </div>


      </div>

      <div id="method-i-flags-3D" class="method-detail ">
        <div class="method-heading">
          <span class="method-callseq">
            flags = flags
          </span>
          <span class="method-click-advice">click to toggle source</span>
        </div>

        <div class="method-description">
          <p>Sets the default flags used by certificate chain verification performed with the <a href="Store.html"><code>Store</code></a>.</p>

<p><em>flags</em> consists of zero or more of the constants defined in <a href="../X509.html"><code>OpenSSL::X509</code></a> with name V_FLAG_* or’ed together.</p>

<p><a href="StoreContext.html#method-i-flags-3D"><code>OpenSSL::X509::StoreContext#flags=</code></a> can be used to change the flags for a single verification operation.</p>

<p>See also the man page X509_VERIFY_PARAM_set_flags(3).</p>

          <div class="method-source-code" id="flags-3D-source">
            <pre>static VALUE
ossl_x509store_set_flags(VALUE self, VALUE flags)
{
    X509_STORE *store;
    long f = NUM2LONG(flags);

    GetX509Store(self, store);
    X509_STORE_set_flags(store, f);

    return flags;
}</pre>
          </div>
        </div>


      </div>

      <div id="method-i-purpose-3D" class="method-detail ">
        <div class="method-heading">
          <span class="method-callseq">
            purpose = purpose
          </span>
          <span class="method-click-advice">click to toggle source</span>
        </div>

        <div class="method-description">
          <p>Sets the store’s default verification purpose. If specified, the verifications on the store will check every certificate’s extensions are consistent with the purpose. The purpose is specified by constants:</p>
<ul><li>
<p>X509::PURPOSE_SSL_CLIENT</p>
</li><li>
<p>X509::PURPOSE_SSL_SERVER</p>
</li><li>
<p>X509::PURPOSE_NS_SSL_SERVER</p>
</li><li>
<p>X509::PURPOSE_SMIME_SIGN</p>
</li><li>
<p>X509::PURPOSE_SMIME_ENCRYPT</p>
</li><li>
<p>X509::PURPOSE_CRL_SIGN</p>
</li><li>
<p>X509::PURPOSE_ANY</p>
</li><li>
<p>X509::PURPOSE_OCSP_HELPER</p>
</li><li>
<p>X509::PURPOSE_TIMESTAMP_SIGN</p>
</li></ul>

<p><a href="StoreContext.html#method-i-purpose-3D"><code>OpenSSL::X509::StoreContext#purpose=</code></a> can be used to change the value for a single verification operation.</p>

<p>See also the man page X509_VERIFY_PARAM_set_purpose(3).</p>

          <div class="method-source-code" id="purpose-3D-source">
            <pre>static VALUE
ossl_x509store_set_purpose(VALUE self, VALUE purpose)
{
    X509_STORE *store;
    int p = NUM2INT(purpose);

    GetX509Store(self, store);
    X509_STORE_set_purpose(store, p);

    return purpose;
}</pre>
          </div>
        </div>


      </div>

      <div id="method-i-set_default_paths" class="method-detail ">
        <div class="method-heading">
          <span class="method-callseq">
            set_default_paths
          </span>
          <span class="method-click-advice">click to toggle source</span>
        </div>

        <div class="method-description">
          <p>Configures <em>store</em> to look up CA certificates from the system default certificate store as needed basis. The location of the store can usually be determined by:</p>
<ul><li>
<p>OpenSSL::X509::DEFAULT_CERT_FILE</p>
</li><li>
<p>OpenSSL::X509::DEFAULT_CERT_DIR</p>
</li></ul>

<p>See also the man page X509_STORE_set_default_paths(3).</p>

          <div class="method-source-code" id="set_default_paths-source">
            <pre>static VALUE
ossl_x509store_set_default_paths(VALUE self)
{
    X509_STORE *store;

    GetX509Store(self, store);
    if (X509_STORE_set_default_paths(store) != 1)
        ossl_raise(eX509StoreError, &quot;X509_STORE_set_default_paths&quot;);

    return Qnil;
}</pre>
          </div>
        </div>


      </div>

      <div id="method-i-time-3D" class="method-detail ">
        <div class="method-heading">
          <span class="method-callseq">
            time = time
          </span>
          <span class="method-click-advice">click to toggle source</span>
        </div>

        <div class="method-description">
          <p>Sets the time to be used in the certificate verifications with the store. By default, if not specified, the current system time is used.</p>

<p><a href="StoreContext.html#method-i-time-3D"><code>OpenSSL::X509::StoreContext#time=</code></a> can be used to change the value for a single verification operation.</p>

<p>See also the man page X509_VERIFY_PARAM_set_time(3).</p>

          <div class="method-source-code" id="time-3D-source">
            <pre>static VALUE
ossl_x509store_set_time(VALUE self, VALUE time)
{
    rb_iv_set(self, &quot;@time&quot;, time);
    return time;
}</pre>
          </div>
        </div>


      </div>

      <div id="method-i-trust-3D" class="method-detail ">
        <div class="method-heading">
          <span class="method-callseq">
            trust = trust
          </span>
          <span class="method-click-advice">click to toggle source</span>
        </div>

        <div class="method-description">
          <p>Sets the default trust settings used by the certificate verification with the store.</p>

<p><a href="StoreContext.html#method-i-trust-3D"><code>OpenSSL::X509::StoreContext#trust=</code></a> can be used to change the value for a single verification operation.</p>

<p>See also the man page X509_VERIFY_PARAM_set_trust(3).</p>

          <div class="method-source-code" id="trust-3D-source">
            <pre>static VALUE
ossl_x509store_set_trust(VALUE self, VALUE trust)
{
    X509_STORE *store;
    int t = NUM2INT(trust);

    GetX509Store(self, store);
    X509_STORE_set_trust(store, t);

    return trust;
}</pre>
          </div>
        </div>


      </div>

      <div id="method-i-verify" class="method-detail ">
        <div class="method-heading">
          <span class="method-callseq">
            verify(cert, chain = nil) &rarr; true | false
          </span>
          <span class="method-click-advice">click to toggle source</span>
        </div>

        <div class="method-description">
          <p>Performs a certificate verification on the <a href="Certificate.html"><code>OpenSSL::X509::Certificate</code></a> <em>cert</em>.</p>

<p><em>chain</em> can be an array of <a href="Certificate.html"><code>OpenSSL::X509::Certificate</code></a> that is used to construct the certificate chain.</p>

<p>If a block is given, it overrides the callback set by <a href="Store.html#method-i-verify_callback-3D"><code>verify_callback=</code></a>.</p>

<p>After finishing the verification, the error information can be retrieved by <a href="Store.html#attribute-i-error"><code>error</code></a>, <a href="Store.html#attribute-i-error_string"><code>error_string</code></a>, and the resulting complete certificate chain can be retrieved by <a href="Store.html#attribute-i-chain"><code>chain</code></a>.</p>

          <div class="method-source-code" id="verify-source">
            <pre>static VALUE
ossl_x509store_verify(int argc, VALUE *argv, VALUE self)
{
    VALUE cert, chain;
    VALUE ctx, proc, result;

    rb_scan_args(argc, argv, &quot;11&quot;, &amp;cert, &amp;chain);
    ctx = rb_funcall(cX509StoreContext, rb_intern(&quot;new&quot;), 3, self, cert, chain);
    proc = rb_block_given_p() ?  rb_block_proc() :
           rb_iv_get(self, &quot;@verify_callback&quot;);
    rb_iv_set(ctx, &quot;@verify_callback&quot;, proc);
    result = rb_funcall(ctx, rb_intern(&quot;verify&quot;), 0);

    rb_iv_set(self, &quot;@error&quot;, ossl_x509stctx_get_err(ctx));
    rb_iv_set(self, &quot;@error_string&quot;, ossl_x509stctx_get_err_string(ctx));
    rb_iv_set(self, &quot;@chain&quot;, ossl_x509stctx_get_chain(ctx));

    return result;
}</pre>
          </div>
        </div>


      </div>

      <div id="method-i-verify_callback-3D" class="method-detail ">
        <div class="method-heading">
          <span class="method-name">verify_callback=</span><span
            class="method-args">(p1)</span>
          <span class="method-click-advice">click to toggle source</span>
        </div>

        <div class="method-description">
          <p>General callback for <a href="../../OpenSSL.html"><code>OpenSSL</code></a> verify</p>

          <div class="method-source-code" id="verify_callback-3D-source">
            <pre>static VALUE
ossl_x509store_set_vfy_cb(VALUE self, VALUE cb)
{
    X509_STORE *store;

    GetX509Store(self, store);
    X509_STORE_set_ex_data(store, store_ex_verify_cb_idx, (void *)cb);
    rb_iv_set(self, &quot;@verify_callback&quot;, cb);

    return cb;
}</pre>
          </div>
        </div>


      </div>

    </section>

  </section>
</main>


<footer id="validator-badges" role="contentinfo">
  <p><a href="https://validator.w3.org/check/referer">Validate</a>
  <p>Generated by <a href="https://ruby.github.io/rdoc/">RDoc</a> 6.3.2.
  <p>Based on <a href="http://deveiate.org/projects/Darkfish-RDoc/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.
</footer>