2 * Copyright 1995-2018 The OpenSSL Project Authors. All Rights Reserved.
4 * Licensed under the Apache License 2.0 (the "License"). You may not use
5 * this file except in compliance with the License. You can obtain a copy
6 * in the file LICENSE in the source distribution or at
7 * https://www.openssl.org/source/license.html
11 #include "internal/cryptlib.h"
12 #include "internal/refcount.h"
13 #include <openssl/x509.h>
14 #include "crypto/x509.h"
15 #include <openssl/x509v3.h>
16 #include "x509_local.h"
18 X509_LOOKUP
*X509_LOOKUP_new(X509_LOOKUP_METHOD
*method
)
20 X509_LOOKUP
*ret
= OPENSSL_zalloc(sizeof(*ret
));
23 X509err(X509_F_X509_LOOKUP_NEW
, ERR_R_MALLOC_FAILURE
);
28 if (method
->new_item
!= NULL
&& method
->new_item(ret
) == 0) {
35 void X509_LOOKUP_free(X509_LOOKUP
*ctx
)
39 if ((ctx
->method
!= NULL
) && (ctx
->method
->free
!= NULL
))
40 (*ctx
->method
->free
) (ctx
);
44 int X509_STORE_lock(X509_STORE
*s
)
46 return CRYPTO_THREAD_write_lock(s
->lock
);
49 int X509_STORE_unlock(X509_STORE
*s
)
51 return CRYPTO_THREAD_unlock(s
->lock
);
54 int X509_LOOKUP_init(X509_LOOKUP
*ctx
)
56 if (ctx
->method
== NULL
)
58 if (ctx
->method
->init
!= NULL
)
59 return ctx
->method
->init(ctx
);
64 int X509_LOOKUP_shutdown(X509_LOOKUP
*ctx
)
66 if (ctx
->method
== NULL
)
68 if (ctx
->method
->shutdown
!= NULL
)
69 return ctx
->method
->shutdown(ctx
);
74 int X509_LOOKUP_ctrl(X509_LOOKUP
*ctx
, int cmd
, const char *argc
, long argl
,
77 if (ctx
->method
== NULL
)
79 if (ctx
->method
->ctrl
!= NULL
)
80 return ctx
->method
->ctrl(ctx
, cmd
, argc
, argl
, ret
);
85 int X509_LOOKUP_by_subject(X509_LOOKUP
*ctx
, X509_LOOKUP_TYPE type
,
86 X509_NAME
*name
, X509_OBJECT
*ret
)
88 if ((ctx
->method
== NULL
) || (ctx
->method
->get_by_subject
== NULL
))
92 return ctx
->method
->get_by_subject(ctx
, type
, name
, ret
);
95 int X509_LOOKUP_by_issuer_serial(X509_LOOKUP
*ctx
, X509_LOOKUP_TYPE type
,
96 X509_NAME
*name
, ASN1_INTEGER
*serial
,
99 if ((ctx
->method
== NULL
) || (ctx
->method
->get_by_issuer_serial
== NULL
))
101 return ctx
->method
->get_by_issuer_serial(ctx
, type
, name
, serial
, ret
);
104 int X509_LOOKUP_by_fingerprint(X509_LOOKUP
*ctx
, X509_LOOKUP_TYPE type
,
105 const unsigned char *bytes
, int len
,
108 if ((ctx
->method
== NULL
) || (ctx
->method
->get_by_fingerprint
== NULL
))
110 return ctx
->method
->get_by_fingerprint(ctx
, type
, bytes
, len
, ret
);
113 int X509_LOOKUP_by_alias(X509_LOOKUP
*ctx
, X509_LOOKUP_TYPE type
,
114 const char *str
, int len
, X509_OBJECT
*ret
)
116 if ((ctx
->method
== NULL
) || (ctx
->method
->get_by_alias
== NULL
))
118 return ctx
->method
->get_by_alias(ctx
, type
, str
, len
, ret
);
121 int X509_LOOKUP_set_method_data(X509_LOOKUP
*ctx
, void *data
)
123 ctx
->method_data
= data
;
127 void *X509_LOOKUP_get_method_data(const X509_LOOKUP
*ctx
)
129 return ctx
->method_data
;
132 X509_STORE
*X509_LOOKUP_get_store(const X509_LOOKUP
*ctx
)
134 return ctx
->store_ctx
;
138 static int x509_object_cmp(const X509_OBJECT
*const *a
,
139 const X509_OBJECT
*const *b
)
143 ret
= ((*a
)->type
- (*b
)->type
);
146 switch ((*a
)->type
) {
148 ret
= X509_subject_name_cmp((*a
)->data
.x509
, (*b
)->data
.x509
);
151 ret
= X509_CRL_cmp((*a
)->data
.crl
, (*b
)->data
.crl
);
160 X509_STORE
*X509_STORE_new(void)
162 X509_STORE
*ret
= OPENSSL_zalloc(sizeof(*ret
));
165 X509err(X509_F_X509_STORE_NEW
, ERR_R_MALLOC_FAILURE
);
168 if ((ret
->objs
= sk_X509_OBJECT_new(x509_object_cmp
)) == NULL
) {
169 X509err(X509_F_X509_STORE_NEW
, ERR_R_MALLOC_FAILURE
);
173 if ((ret
->get_cert_methods
= sk_X509_LOOKUP_new_null()) == NULL
) {
174 X509err(X509_F_X509_STORE_NEW
, ERR_R_MALLOC_FAILURE
);
178 if ((ret
->param
= X509_VERIFY_PARAM_new()) == NULL
) {
179 X509err(X509_F_X509_STORE_NEW
, ERR_R_MALLOC_FAILURE
);
182 if (!CRYPTO_new_ex_data(CRYPTO_EX_INDEX_X509_STORE
, ret
, &ret
->ex_data
)) {
183 X509err(X509_F_X509_STORE_NEW
, ERR_R_MALLOC_FAILURE
);
187 ret
->lock
= CRYPTO_THREAD_lock_new();
188 if (ret
->lock
== NULL
) {
189 X509err(X509_F_X509_STORE_NEW
, ERR_R_MALLOC_FAILURE
);
197 X509_VERIFY_PARAM_free(ret
->param
);
198 sk_X509_OBJECT_free(ret
->objs
);
199 sk_X509_LOOKUP_free(ret
->get_cert_methods
);
204 void X509_STORE_free(X509_STORE
*vfy
)
207 STACK_OF(X509_LOOKUP
) *sk
;
212 CRYPTO_DOWN_REF(&vfy
->references
, &i
, vfy
->lock
);
213 REF_PRINT_COUNT("X509_STORE", vfy
);
216 REF_ASSERT_ISNT(i
< 0);
218 sk
= vfy
->get_cert_methods
;
219 for (i
= 0; i
< sk_X509_LOOKUP_num(sk
); i
++) {
220 lu
= sk_X509_LOOKUP_value(sk
, i
);
221 X509_LOOKUP_shutdown(lu
);
222 X509_LOOKUP_free(lu
);
224 sk_X509_LOOKUP_free(sk
);
225 sk_X509_OBJECT_pop_free(vfy
->objs
, X509_OBJECT_free
);
227 CRYPTO_free_ex_data(CRYPTO_EX_INDEX_X509_STORE
, vfy
, &vfy
->ex_data
);
228 X509_VERIFY_PARAM_free(vfy
->param
);
229 CRYPTO_THREAD_lock_free(vfy
->lock
);
233 int X509_STORE_up_ref(X509_STORE
*vfy
)
237 if (CRYPTO_UP_REF(&vfy
->references
, &i
, vfy
->lock
) <= 0)
240 REF_PRINT_COUNT("X509_STORE", vfy
);
241 REF_ASSERT_ISNT(i
< 2);
242 return ((i
> 1) ? 1 : 0);
245 X509_LOOKUP
*X509_STORE_add_lookup(X509_STORE
*v
, X509_LOOKUP_METHOD
*m
)
248 STACK_OF(X509_LOOKUP
) *sk
;
251 sk
= v
->get_cert_methods
;
252 for (i
= 0; i
< sk_X509_LOOKUP_num(sk
); i
++) {
253 lu
= sk_X509_LOOKUP_value(sk
, i
);
254 if (m
== lu
->method
) {
259 lu
= X509_LOOKUP_new(m
);
261 X509err(X509_F_X509_STORE_ADD_LOOKUP
, ERR_R_MALLOC_FAILURE
);
266 if (sk_X509_LOOKUP_push(v
->get_cert_methods
, lu
))
269 X509err(X509_F_X509_STORE_ADD_LOOKUP
, ERR_R_MALLOC_FAILURE
);
270 X509_LOOKUP_free(lu
);
274 X509_OBJECT
*X509_STORE_CTX_get_obj_by_subject(X509_STORE_CTX
*vs
,
275 X509_LOOKUP_TYPE type
,
278 X509_OBJECT
*ret
= X509_OBJECT_new();
282 if (!X509_STORE_CTX_get_by_subject(vs
, type
, name
, ret
)) {
283 X509_OBJECT_free(ret
);
289 int X509_STORE_CTX_get_by_subject(X509_STORE_CTX
*vs
, X509_LOOKUP_TYPE type
,
290 X509_NAME
*name
, X509_OBJECT
*ret
)
292 X509_STORE
*store
= vs
->store
;
294 X509_OBJECT stmp
, *tmp
;
300 stmp
.type
= X509_LU_NONE
;
301 stmp
.data
.ptr
= NULL
;
304 X509_STORE_lock(store
);
305 tmp
= X509_OBJECT_retrieve_by_subject(store
->objs
, type
, name
);
306 X509_STORE_unlock(store
);
308 if (tmp
== NULL
|| type
== X509_LU_CRL
) {
309 for (i
= 0; i
< sk_X509_LOOKUP_num(store
->get_cert_methods
); i
++) {
310 lu
= sk_X509_LOOKUP_value(store
->get_cert_methods
, i
);
311 j
= X509_LOOKUP_by_subject(lu
, type
, name
, &stmp
);
321 if (!X509_OBJECT_up_ref_count(tmp
))
324 ret
->type
= tmp
->type
;
325 ret
->data
.ptr
= tmp
->data
.ptr
;
330 static int x509_store_add(X509_STORE
*store
, void *x
, int crl
) {
332 int ret
= 0, added
= 0;
336 obj
= X509_OBJECT_new();
341 obj
->type
= X509_LU_CRL
;
342 obj
->data
.crl
= (X509_CRL
*)x
;
344 obj
->type
= X509_LU_X509
;
345 obj
->data
.x509
= (X509
*)x
;
347 if (!X509_OBJECT_up_ref_count(obj
)) {
348 obj
->type
= X509_LU_NONE
;
349 X509_OBJECT_free(obj
);
353 X509_STORE_lock(store
);
354 if (X509_OBJECT_retrieve_match(store
->objs
, obj
)) {
357 added
= sk_X509_OBJECT_push(store
->objs
, obj
);
360 X509_STORE_unlock(store
);
362 if (added
== 0) /* obj not pushed */
363 X509_OBJECT_free(obj
);
368 int X509_STORE_add_cert(X509_STORE
*ctx
, X509
*x
)
370 if (!x509_store_add(ctx
, x
, 0)) {
371 X509err(X509_F_X509_STORE_ADD_CERT
, ERR_R_MALLOC_FAILURE
);
377 int X509_STORE_add_crl(X509_STORE
*ctx
, X509_CRL
*x
)
379 if (!x509_store_add(ctx
, x
, 1)) {
380 X509err(X509_F_X509_STORE_ADD_CRL
, ERR_R_MALLOC_FAILURE
);
386 int X509_OBJECT_up_ref_count(X509_OBJECT
*a
)
392 return X509_up_ref(a
->data
.x509
);
394 return X509_CRL_up_ref(a
->data
.crl
);
399 X509
*X509_OBJECT_get0_X509(const X509_OBJECT
*a
)
401 if (a
== NULL
|| a
->type
!= X509_LU_X509
)
406 X509_CRL
*X509_OBJECT_get0_X509_CRL(X509_OBJECT
*a
)
408 if (a
== NULL
|| a
->type
!= X509_LU_CRL
)
413 X509_LOOKUP_TYPE
X509_OBJECT_get_type(const X509_OBJECT
*a
)
418 X509_OBJECT
*X509_OBJECT_new(void)
420 X509_OBJECT
*ret
= OPENSSL_zalloc(sizeof(*ret
));
423 X509err(X509_F_X509_OBJECT_NEW
, ERR_R_MALLOC_FAILURE
);
426 ret
->type
= X509_LU_NONE
;
430 static void x509_object_free_internal(X509_OBJECT
*a
)
438 X509_free(a
->data
.x509
);
441 X509_CRL_free(a
->data
.crl
);
446 int X509_OBJECT_set1_X509(X509_OBJECT
*a
, X509
*obj
)
448 if (a
== NULL
|| !X509_up_ref(obj
))
451 x509_object_free_internal(a
);
452 a
->type
= X509_LU_X509
;
457 int X509_OBJECT_set1_X509_CRL(X509_OBJECT
*a
, X509_CRL
*obj
)
459 if (a
== NULL
|| !X509_CRL_up_ref(obj
))
462 x509_object_free_internal(a
);
463 a
->type
= X509_LU_CRL
;
468 void X509_OBJECT_free(X509_OBJECT
*a
)
470 x509_object_free_internal(a
);
474 static int x509_object_idx_cnt(STACK_OF(X509_OBJECT
) *h
, X509_LOOKUP_TYPE type
,
475 X509_NAME
*name
, int *pnmatch
)
485 stmp
.data
.x509
= &x509_s
;
486 x509_s
.cert_info
.subject
= name
;
489 stmp
.data
.crl
= &crl_s
;
490 crl_s
.crl
.issuer
= name
;
497 idx
= sk_X509_OBJECT_find(h
, &stmp
);
498 if (idx
>= 0 && pnmatch
) {
500 const X509_OBJECT
*tobj
, *pstmp
;
503 for (tidx
= idx
+ 1; tidx
< sk_X509_OBJECT_num(h
); tidx
++) {
504 tobj
= sk_X509_OBJECT_value(h
, tidx
);
505 if (x509_object_cmp(&tobj
, &pstmp
))
513 int X509_OBJECT_idx_by_subject(STACK_OF(X509_OBJECT
) *h
, X509_LOOKUP_TYPE type
,
516 return x509_object_idx_cnt(h
, type
, name
, NULL
);
519 X509_OBJECT
*X509_OBJECT_retrieve_by_subject(STACK_OF(X509_OBJECT
) *h
,
520 X509_LOOKUP_TYPE type
,
524 idx
= X509_OBJECT_idx_by_subject(h
, type
, name
);
527 return sk_X509_OBJECT_value(h
, idx
);
530 STACK_OF(X509_OBJECT
) *X509_STORE_get0_objects(X509_STORE
*v
)
535 STACK_OF(X509
) *X509_STORE_get1_all_certs(X509_STORE
*store
)
538 STACK_OF(X509_OBJECT
) *objs
;
542 X509err(0, ERR_R_PASSED_NULL_PARAMETER
);
545 if ((sk
= sk_X509_new_null()) == NULL
)
547 X509_STORE_lock(store
);
548 objs
= X509_STORE_get0_objects(store
);
549 for (i
= 0; i
< sk_X509_OBJECT_num(objs
); i
++) {
550 X509
*cert
= X509_OBJECT_get0_X509(sk_X509_OBJECT_value(objs
, i
));
553 if (!X509_up_ref(cert
))
555 if (!sk_X509_push(sk
, cert
)) {
561 X509_STORE_unlock(store
);
565 X509_STORE_unlock(store
);
566 sk_X509_pop_free(sk
, X509_free
);
570 STACK_OF(X509
) *X509_STORE_CTX_get1_certs(X509_STORE_CTX
*ctx
, X509_NAME
*nm
)
573 STACK_OF(X509
) *sk
= NULL
;
576 X509_STORE
*store
= ctx
->store
;
581 X509_STORE_lock(store
);
582 idx
= x509_object_idx_cnt(store
->objs
, X509_LU_X509
, nm
, &cnt
);
585 * Nothing found in cache: do lookup to possibly add new objects to
588 X509_OBJECT
*xobj
= X509_OBJECT_new();
590 X509_STORE_unlock(store
);
594 if (!X509_STORE_CTX_get_by_subject(ctx
, X509_LU_X509
, nm
, xobj
)) {
595 X509_OBJECT_free(xobj
);
598 X509_OBJECT_free(xobj
);
599 X509_STORE_lock(store
);
600 idx
= x509_object_idx_cnt(store
->objs
, X509_LU_X509
, nm
, &cnt
);
602 X509_STORE_unlock(store
);
607 sk
= sk_X509_new_null();
608 for (i
= 0; i
< cnt
; i
++, idx
++) {
609 obj
= sk_X509_OBJECT_value(store
->objs
, idx
);
611 if (!X509_up_ref(x
)) {
612 X509_STORE_unlock(store
);
613 sk_X509_pop_free(sk
, X509_free
);
616 if (!sk_X509_push(sk
, x
)) {
617 X509_STORE_unlock(store
);
619 sk_X509_pop_free(sk
, X509_free
);
623 X509_STORE_unlock(store
);
627 STACK_OF(X509_CRL
) *X509_STORE_CTX_get1_crls(X509_STORE_CTX
*ctx
, X509_NAME
*nm
)
630 STACK_OF(X509_CRL
) *sk
= sk_X509_CRL_new_null();
632 X509_OBJECT
*obj
, *xobj
= X509_OBJECT_new();
633 X509_STORE
*store
= ctx
->store
;
635 /* Always do lookup to possibly add new CRLs to cache */
639 || !X509_STORE_CTX_get_by_subject(ctx
, X509_LU_CRL
, nm
, xobj
)) {
640 X509_OBJECT_free(xobj
);
641 sk_X509_CRL_free(sk
);
644 X509_OBJECT_free(xobj
);
645 X509_STORE_lock(store
);
646 idx
= x509_object_idx_cnt(store
->objs
, X509_LU_CRL
, nm
, &cnt
);
648 X509_STORE_unlock(store
);
649 sk_X509_CRL_free(sk
);
653 for (i
= 0; i
< cnt
; i
++, idx
++) {
654 obj
= sk_X509_OBJECT_value(store
->objs
, idx
);
656 if (!X509_CRL_up_ref(x
)) {
657 X509_STORE_unlock(store
);
658 sk_X509_CRL_pop_free(sk
, X509_CRL_free
);
661 if (!sk_X509_CRL_push(sk
, x
)) {
662 X509_STORE_unlock(store
);
664 sk_X509_CRL_pop_free(sk
, X509_CRL_free
);
668 X509_STORE_unlock(store
);
672 X509_OBJECT
*X509_OBJECT_retrieve_match(STACK_OF(X509_OBJECT
) *h
,
678 idx
= sk_X509_OBJECT_find(h
, x
);
681 if ((x
->type
!= X509_LU_X509
) && (x
->type
!= X509_LU_CRL
))
682 return sk_X509_OBJECT_value(h
, idx
);
683 for (i
= idx
, num
= sk_X509_OBJECT_num(h
); i
< num
; i
++) {
684 obj
= sk_X509_OBJECT_value(h
, i
);
685 if (x509_object_cmp((const X509_OBJECT
**)&obj
,
686 (const X509_OBJECT
**)&x
))
688 if (x
->type
== X509_LU_X509
) {
689 if (!X509_cmp(obj
->data
.x509
, x
->data
.x509
))
691 } else if (x
->type
== X509_LU_CRL
) {
692 if (!X509_CRL_match(obj
->data
.crl
, x
->data
.crl
))
701 * Try to get issuer certificate from store. Due to limitations
702 * of the API this can only retrieve a single certificate matching
703 * a given subject name. However it will fill the cache with all
704 * matching certificates, so we can examine the cache for all
708 * 1 lookup successful.
709 * 0 certificate not found.
710 * -1 some other error.
712 int X509_STORE_CTX_get1_issuer(X509
**issuer
, X509_STORE_CTX
*ctx
, X509
*x
)
715 X509_OBJECT
*obj
= X509_OBJECT_new(), *pobj
= NULL
;
716 X509_STORE
*store
= ctx
->store
;
722 xn
= X509_get_issuer_name(x
);
723 ok
= X509_STORE_CTX_get_by_subject(ctx
, X509_LU_X509
, xn
, obj
);
725 X509_OBJECT_free(obj
);
728 /* If certificate matches all OK */
729 if (ctx
->check_issued(ctx
, x
, obj
->data
.x509
)) {
730 if (x509_check_cert_time(ctx
, obj
->data
.x509
, -1)) {
731 *issuer
= obj
->data
.x509
;
732 if (!X509_up_ref(*issuer
)) {
736 X509_OBJECT_free(obj
);
740 X509_OBJECT_free(obj
);
745 /* Else find index of first cert accepted by 'check_issued' */
747 X509_STORE_lock(store
);
748 idx
= X509_OBJECT_idx_by_subject(store
->objs
, X509_LU_X509
, xn
);
749 if (idx
!= -1) { /* should be true as we've had at least one
751 /* Look through all matching certs for suitable issuer */
752 for (i
= idx
; i
< sk_X509_OBJECT_num(store
->objs
); i
++) {
753 pobj
= sk_X509_OBJECT_value(store
->objs
, i
);
754 /* See if we've run past the matches */
755 if (pobj
->type
!= X509_LU_X509
)
757 if (X509_NAME_cmp(xn
, X509_get_subject_name(pobj
->data
.x509
)))
759 if (ctx
->check_issued(ctx
, x
, pobj
->data
.x509
)) {
760 *issuer
= pobj
->data
.x509
;
763 * If times check, exit with match,
764 * otherwise keep looking. Leave last
765 * match in issuer so we return nearest
766 * match if no certificate time is OK.
769 if (x509_check_cert_time(ctx
, *issuer
, -1))
774 if (*issuer
&& !X509_up_ref(*issuer
)) {
778 X509_STORE_unlock(store
);
782 int X509_STORE_set_flags(X509_STORE
*ctx
, unsigned long flags
)
784 return X509_VERIFY_PARAM_set_flags(ctx
->param
, flags
);
787 int X509_STORE_set_depth(X509_STORE
*ctx
, int depth
)
789 X509_VERIFY_PARAM_set_depth(ctx
->param
, depth
);
793 int X509_STORE_set_purpose(X509_STORE
*ctx
, int purpose
)
795 return X509_VERIFY_PARAM_set_purpose(ctx
->param
, purpose
);
798 int X509_STORE_set_trust(X509_STORE
*ctx
, int trust
)
800 return X509_VERIFY_PARAM_set_trust(ctx
->param
, trust
);
803 int X509_STORE_set1_param(X509_STORE
*ctx
, X509_VERIFY_PARAM
*param
)
805 return X509_VERIFY_PARAM_set1(ctx
->param
, param
);
808 X509_VERIFY_PARAM
*X509_STORE_get0_param(X509_STORE
*ctx
)
813 void X509_STORE_set_verify(X509_STORE
*ctx
, X509_STORE_CTX_verify_fn verify
)
815 ctx
->verify
= verify
;
818 X509_STORE_CTX_verify_fn
X509_STORE_get_verify(X509_STORE
*ctx
)
823 void X509_STORE_set_verify_cb(X509_STORE
*ctx
,
824 X509_STORE_CTX_verify_cb verify_cb
)
826 ctx
->verify_cb
= verify_cb
;
829 X509_STORE_CTX_verify_cb
X509_STORE_get_verify_cb(X509_STORE
*ctx
)
831 return ctx
->verify_cb
;
834 void X509_STORE_set_get_issuer(X509_STORE
*ctx
,
835 X509_STORE_CTX_get_issuer_fn get_issuer
)
837 ctx
->get_issuer
= get_issuer
;
840 X509_STORE_CTX_get_issuer_fn
X509_STORE_get_get_issuer(X509_STORE
*ctx
)
842 return ctx
->get_issuer
;
845 void X509_STORE_set_check_issued(X509_STORE
*ctx
,
846 X509_STORE_CTX_check_issued_fn check_issued
)
848 ctx
->check_issued
= check_issued
;
851 X509_STORE_CTX_check_issued_fn
X509_STORE_get_check_issued(X509_STORE
*ctx
)
853 return ctx
->check_issued
;
856 void X509_STORE_set_check_revocation(X509_STORE
*ctx
,
857 X509_STORE_CTX_check_revocation_fn check_revocation
)
859 ctx
->check_revocation
= check_revocation
;
862 X509_STORE_CTX_check_revocation_fn
X509_STORE_get_check_revocation(X509_STORE
*ctx
)
864 return ctx
->check_revocation
;
867 void X509_STORE_set_get_crl(X509_STORE
*ctx
,
868 X509_STORE_CTX_get_crl_fn get_crl
)
870 ctx
->get_crl
= get_crl
;
873 X509_STORE_CTX_get_crl_fn
X509_STORE_get_get_crl(X509_STORE
*ctx
)
878 void X509_STORE_set_check_crl(X509_STORE
*ctx
,
879 X509_STORE_CTX_check_crl_fn check_crl
)
881 ctx
->check_crl
= check_crl
;
884 X509_STORE_CTX_check_crl_fn
X509_STORE_get_check_crl(X509_STORE
*ctx
)
886 return ctx
->check_crl
;
889 void X509_STORE_set_cert_crl(X509_STORE
*ctx
,
890 X509_STORE_CTX_cert_crl_fn cert_crl
)
892 ctx
->cert_crl
= cert_crl
;
895 X509_STORE_CTX_cert_crl_fn
X509_STORE_get_cert_crl(X509_STORE
*ctx
)
897 return ctx
->cert_crl
;
900 void X509_STORE_set_check_policy(X509_STORE
*ctx
,
901 X509_STORE_CTX_check_policy_fn check_policy
)
903 ctx
->check_policy
= check_policy
;
906 X509_STORE_CTX_check_policy_fn
X509_STORE_get_check_policy(X509_STORE
*ctx
)
908 return ctx
->check_policy
;
911 void X509_STORE_set_lookup_certs(X509_STORE
*ctx
,
912 X509_STORE_CTX_lookup_certs_fn lookup_certs
)
914 ctx
->lookup_certs
= lookup_certs
;
917 X509_STORE_CTX_lookup_certs_fn
X509_STORE_get_lookup_certs(X509_STORE
*ctx
)
919 return ctx
->lookup_certs
;
922 void X509_STORE_set_lookup_crls(X509_STORE
*ctx
,
923 X509_STORE_CTX_lookup_crls_fn lookup_crls
)
925 ctx
->lookup_crls
= lookup_crls
;
928 X509_STORE_CTX_lookup_crls_fn
X509_STORE_get_lookup_crls(X509_STORE
*ctx
)
930 return ctx
->lookup_crls
;
933 void X509_STORE_set_cleanup(X509_STORE
*ctx
,
934 X509_STORE_CTX_cleanup_fn ctx_cleanup
)
936 ctx
->cleanup
= ctx_cleanup
;
939 X509_STORE_CTX_cleanup_fn
X509_STORE_get_cleanup(X509_STORE
*ctx
)
944 int X509_STORE_set_ex_data(X509_STORE
*ctx
, int idx
, void *data
)
946 return CRYPTO_set_ex_data(&ctx
->ex_data
, idx
, data
);
949 void *X509_STORE_get_ex_data(X509_STORE
*ctx
, int idx
)
951 return CRYPTO_get_ex_data(&ctx
->ex_data
, idx
);
954 X509_STORE
*X509_STORE_CTX_get0_store(X509_STORE_CTX
*ctx
)