2 * Copyright 1995-2021 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 ERR_raise(ERR_LIB_X509
, 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_ex(X509_LOOKUP
*ctx
, int cmd
, const char *argc
, long argl
,
75 char **ret
, OSSL_LIB_CTX
*libctx
, const char *propq
)
77 if (ctx
->method
== NULL
)
79 if (ctx
->method
->ctrl_ex
!= NULL
)
80 return ctx
->method
->ctrl_ex(ctx
, cmd
, argc
, argl
, ret
, libctx
, propq
);
81 if (ctx
->method
->ctrl
!= NULL
)
82 return ctx
->method
->ctrl(ctx
, cmd
, argc
, argl
, ret
);
86 int X509_LOOKUP_ctrl(X509_LOOKUP
*ctx
, int cmd
, const char *argc
, long argl
,
89 return X509_LOOKUP_ctrl_ex(ctx
, cmd
, argc
, argl
, ret
, NULL
, NULL
);
92 int X509_LOOKUP_by_subject_ex(X509_LOOKUP
*ctx
, X509_LOOKUP_TYPE type
,
93 const X509_NAME
*name
, X509_OBJECT
*ret
,
94 OSSL_LIB_CTX
*libctx
, const char *propq
)
97 || ctx
->method
== NULL
98 || (ctx
->method
->get_by_subject
== NULL
99 && ctx
->method
->get_by_subject_ex
== NULL
))
101 if (ctx
->method
->get_by_subject_ex
!= NULL
)
102 return ctx
->method
->get_by_subject_ex(ctx
, type
, name
, ret
, libctx
,
105 return ctx
->method
->get_by_subject(ctx
, type
, name
, ret
);
108 int X509_LOOKUP_by_subject(X509_LOOKUP
*ctx
, X509_LOOKUP_TYPE type
,
109 const X509_NAME
*name
, X509_OBJECT
*ret
)
111 return X509_LOOKUP_by_subject_ex(ctx
, type
, name
, ret
, NULL
, NULL
);
114 int X509_LOOKUP_by_issuer_serial(X509_LOOKUP
*ctx
, X509_LOOKUP_TYPE type
,
115 const X509_NAME
*name
,
116 const ASN1_INTEGER
*serial
,
119 if ((ctx
->method
== NULL
) || (ctx
->method
->get_by_issuer_serial
== NULL
))
121 return ctx
->method
->get_by_issuer_serial(ctx
, type
, name
, serial
, ret
);
124 int X509_LOOKUP_by_fingerprint(X509_LOOKUP
*ctx
, X509_LOOKUP_TYPE type
,
125 const unsigned char *bytes
, int len
,
128 if ((ctx
->method
== NULL
) || (ctx
->method
->get_by_fingerprint
== NULL
))
130 return ctx
->method
->get_by_fingerprint(ctx
, type
, bytes
, len
, ret
);
133 int X509_LOOKUP_by_alias(X509_LOOKUP
*ctx
, X509_LOOKUP_TYPE type
,
134 const char *str
, int len
, X509_OBJECT
*ret
)
136 if ((ctx
->method
== NULL
) || (ctx
->method
->get_by_alias
== NULL
))
138 return ctx
->method
->get_by_alias(ctx
, type
, str
, len
, ret
);
141 int X509_LOOKUP_set_method_data(X509_LOOKUP
*ctx
, void *data
)
143 ctx
->method_data
= data
;
147 void *X509_LOOKUP_get_method_data(const X509_LOOKUP
*ctx
)
149 return ctx
->method_data
;
152 X509_STORE
*X509_LOOKUP_get_store(const X509_LOOKUP
*ctx
)
154 return ctx
->store_ctx
;
158 static int x509_object_cmp(const X509_OBJECT
*const *a
,
159 const X509_OBJECT
*const *b
)
163 ret
= ((*a
)->type
- (*b
)->type
);
166 switch ((*a
)->type
) {
168 ret
= X509_subject_name_cmp((*a
)->data
.x509
, (*b
)->data
.x509
);
171 ret
= X509_CRL_cmp((*a
)->data
.crl
, (*b
)->data
.crl
);
180 X509_STORE
*X509_STORE_new(void)
182 X509_STORE
*ret
= OPENSSL_zalloc(sizeof(*ret
));
185 ERR_raise(ERR_LIB_X509
, ERR_R_MALLOC_FAILURE
);
188 if ((ret
->objs
= sk_X509_OBJECT_new(x509_object_cmp
)) == NULL
) {
189 ERR_raise(ERR_LIB_X509
, ERR_R_MALLOC_FAILURE
);
193 if ((ret
->get_cert_methods
= sk_X509_LOOKUP_new_null()) == NULL
) {
194 ERR_raise(ERR_LIB_X509
, ERR_R_MALLOC_FAILURE
);
198 if ((ret
->param
= X509_VERIFY_PARAM_new()) == NULL
) {
199 ERR_raise(ERR_LIB_X509
, ERR_R_MALLOC_FAILURE
);
202 if (!CRYPTO_new_ex_data(CRYPTO_EX_INDEX_X509_STORE
, ret
, &ret
->ex_data
)) {
203 ERR_raise(ERR_LIB_X509
, ERR_R_MALLOC_FAILURE
);
207 ret
->lock
= CRYPTO_THREAD_lock_new();
208 if (ret
->lock
== NULL
) {
209 ERR_raise(ERR_LIB_X509
, ERR_R_MALLOC_FAILURE
);
216 X509_VERIFY_PARAM_free(ret
->param
);
217 sk_X509_OBJECT_free(ret
->objs
);
218 sk_X509_LOOKUP_free(ret
->get_cert_methods
);
223 void X509_STORE_free(X509_STORE
*vfy
)
226 STACK_OF(X509_LOOKUP
) *sk
;
231 CRYPTO_DOWN_REF(&vfy
->references
, &i
, vfy
->lock
);
232 REF_PRINT_COUNT("X509_STORE", vfy
);
235 REF_ASSERT_ISNT(i
< 0);
237 sk
= vfy
->get_cert_methods
;
238 for (i
= 0; i
< sk_X509_LOOKUP_num(sk
); i
++) {
239 lu
= sk_X509_LOOKUP_value(sk
, i
);
240 X509_LOOKUP_shutdown(lu
);
241 X509_LOOKUP_free(lu
);
243 sk_X509_LOOKUP_free(sk
);
244 sk_X509_OBJECT_pop_free(vfy
->objs
, X509_OBJECT_free
);
246 CRYPTO_free_ex_data(CRYPTO_EX_INDEX_X509_STORE
, vfy
, &vfy
->ex_data
);
247 X509_VERIFY_PARAM_free(vfy
->param
);
248 CRYPTO_THREAD_lock_free(vfy
->lock
);
252 int X509_STORE_up_ref(X509_STORE
*vfy
)
256 if (CRYPTO_UP_REF(&vfy
->references
, &i
, vfy
->lock
) <= 0)
259 REF_PRINT_COUNT("X509_STORE", vfy
);
260 REF_ASSERT_ISNT(i
< 2);
261 return ((i
> 1) ? 1 : 0);
264 X509_LOOKUP
*X509_STORE_add_lookup(X509_STORE
*v
, X509_LOOKUP_METHOD
*m
)
267 STACK_OF(X509_LOOKUP
) *sk
;
270 sk
= v
->get_cert_methods
;
271 for (i
= 0; i
< sk_X509_LOOKUP_num(sk
); i
++) {
272 lu
= sk_X509_LOOKUP_value(sk
, i
);
273 if (m
== lu
->method
) {
278 lu
= X509_LOOKUP_new(m
);
280 ERR_raise(ERR_LIB_X509
, ERR_R_MALLOC_FAILURE
);
285 if (sk_X509_LOOKUP_push(v
->get_cert_methods
, lu
))
288 ERR_raise(ERR_LIB_X509
, ERR_R_MALLOC_FAILURE
);
289 X509_LOOKUP_free(lu
);
293 X509_OBJECT
*X509_STORE_CTX_get_obj_by_subject(X509_STORE_CTX
*vs
,
294 X509_LOOKUP_TYPE type
,
295 const X509_NAME
*name
)
297 X509_OBJECT
*ret
= X509_OBJECT_new();
301 if (!X509_STORE_CTX_get_by_subject(vs
, type
, name
, ret
)) {
302 X509_OBJECT_free(ret
);
308 /* Also fill the cache with all matching certificates */
309 int X509_STORE_CTX_get_by_subject(const X509_STORE_CTX
*vs
,
310 X509_LOOKUP_TYPE type
,
311 const X509_NAME
*name
, X509_OBJECT
*ret
)
313 X509_STORE
*store
= vs
->store
;
315 X509_OBJECT stmp
, *tmp
;
321 stmp
.type
= X509_LU_NONE
;
322 stmp
.data
.ptr
= NULL
;
324 X509_STORE_lock(store
);
325 tmp
= X509_OBJECT_retrieve_by_subject(store
->objs
, type
, name
);
326 X509_STORE_unlock(store
);
328 if (tmp
== NULL
|| type
== X509_LU_CRL
) {
329 for (i
= 0; i
< sk_X509_LOOKUP_num(store
->get_cert_methods
); i
++) {
330 lu
= sk_X509_LOOKUP_value(store
->get_cert_methods
, i
);
331 j
= X509_LOOKUP_by_subject_ex(lu
, type
, name
, &stmp
, vs
->libctx
,
342 if (!X509_OBJECT_up_ref_count(tmp
))
345 ret
->type
= tmp
->type
;
346 ret
->data
.ptr
= tmp
->data
.ptr
;
351 static int x509_store_add(X509_STORE
*store
, void *x
, int crl
) {
353 int ret
= 0, added
= 0;
357 obj
= X509_OBJECT_new();
362 obj
->type
= X509_LU_CRL
;
363 obj
->data
.crl
= (X509_CRL
*)x
;
365 obj
->type
= X509_LU_X509
;
366 obj
->data
.x509
= (X509
*)x
;
368 if (!X509_OBJECT_up_ref_count(obj
)) {
369 obj
->type
= X509_LU_NONE
;
370 X509_OBJECT_free(obj
);
374 X509_STORE_lock(store
);
375 if (X509_OBJECT_retrieve_match(store
->objs
, obj
)) {
378 added
= sk_X509_OBJECT_push(store
->objs
, obj
);
381 X509_STORE_unlock(store
);
383 if (added
== 0) /* obj not pushed */
384 X509_OBJECT_free(obj
);
389 int X509_STORE_add_cert(X509_STORE
*ctx
, X509
*x
)
391 if (!x509_store_add(ctx
, x
, 0)) {
392 ERR_raise(ERR_LIB_X509
, ERR_R_MALLOC_FAILURE
);
398 int X509_STORE_add_crl(X509_STORE
*ctx
, X509_CRL
*x
)
400 if (!x509_store_add(ctx
, x
, 1)) {
401 ERR_raise(ERR_LIB_X509
, ERR_R_MALLOC_FAILURE
);
407 int X509_OBJECT_up_ref_count(X509_OBJECT
*a
)
413 return X509_up_ref(a
->data
.x509
);
415 return X509_CRL_up_ref(a
->data
.crl
);
420 X509
*X509_OBJECT_get0_X509(const X509_OBJECT
*a
)
422 if (a
== NULL
|| a
->type
!= X509_LU_X509
)
427 X509_CRL
*X509_OBJECT_get0_X509_CRL(const X509_OBJECT
*a
)
429 if (a
== NULL
|| a
->type
!= X509_LU_CRL
)
434 X509_LOOKUP_TYPE
X509_OBJECT_get_type(const X509_OBJECT
*a
)
439 X509_OBJECT
*X509_OBJECT_new(void)
441 X509_OBJECT
*ret
= OPENSSL_zalloc(sizeof(*ret
));
444 ERR_raise(ERR_LIB_X509
, ERR_R_MALLOC_FAILURE
);
447 ret
->type
= X509_LU_NONE
;
451 static void x509_object_free_internal(X509_OBJECT
*a
)
459 X509_free(a
->data
.x509
);
462 X509_CRL_free(a
->data
.crl
);
467 int X509_OBJECT_set1_X509(X509_OBJECT
*a
, X509
*obj
)
469 if (a
== NULL
|| !X509_up_ref(obj
))
472 x509_object_free_internal(a
);
473 a
->type
= X509_LU_X509
;
478 int X509_OBJECT_set1_X509_CRL(X509_OBJECT
*a
, X509_CRL
*obj
)
480 if (a
== NULL
|| !X509_CRL_up_ref(obj
))
483 x509_object_free_internal(a
);
484 a
->type
= X509_LU_CRL
;
489 void X509_OBJECT_free(X509_OBJECT
*a
)
491 x509_object_free_internal(a
);
495 static int x509_object_idx_cnt(STACK_OF(X509_OBJECT
) *h
, X509_LOOKUP_TYPE type
,
496 const X509_NAME
*name
, int *pnmatch
)
506 stmp
.data
.x509
= &x509_s
;
507 x509_s
.cert_info
.subject
= (X509_NAME
*)name
; /* won't modify it */
510 stmp
.data
.crl
= &crl_s
;
511 crl_s
.crl
.issuer
= (X509_NAME
*)name
; /* won't modify it */
518 idx
= sk_X509_OBJECT_find_all(h
, &stmp
, pnmatch
);
522 int X509_OBJECT_idx_by_subject(STACK_OF(X509_OBJECT
) *h
, X509_LOOKUP_TYPE type
,
523 const X509_NAME
*name
)
525 return x509_object_idx_cnt(h
, type
, name
, NULL
);
528 X509_OBJECT
*X509_OBJECT_retrieve_by_subject(STACK_OF(X509_OBJECT
) *h
,
529 X509_LOOKUP_TYPE type
,
530 const X509_NAME
*name
)
533 idx
= X509_OBJECT_idx_by_subject(h
, type
, name
);
536 return sk_X509_OBJECT_value(h
, idx
);
539 STACK_OF(X509_OBJECT
) *X509_STORE_get0_objects(const X509_STORE
*v
)
544 STACK_OF(X509
) *X509_STORE_get1_all_certs(X509_STORE
*store
)
547 STACK_OF(X509_OBJECT
) *objs
;
551 ERR_raise(ERR_LIB_X509
, ERR_R_PASSED_NULL_PARAMETER
);
554 if ((sk
= sk_X509_new_null()) == NULL
)
556 X509_STORE_lock(store
);
557 objs
= X509_STORE_get0_objects(store
);
558 for (i
= 0; i
< sk_X509_OBJECT_num(objs
); i
++) {
559 X509
*cert
= X509_OBJECT_get0_X509(sk_X509_OBJECT_value(objs
, i
));
562 && !X509_add_cert(sk
, cert
, X509_ADD_FLAG_UP_REF
))
565 X509_STORE_unlock(store
);
569 X509_STORE_unlock(store
);
570 sk_X509_pop_free(sk
, X509_free
);
574 STACK_OF(X509
) *X509_STORE_CTX_get1_certs(X509_STORE_CTX
*ctx
,
578 STACK_OF(X509
) *sk
= NULL
;
581 X509_STORE
*store
= ctx
->store
;
586 X509_STORE_lock(store
);
587 idx
= x509_object_idx_cnt(store
->objs
, X509_LU_X509
, nm
, &cnt
);
590 * Nothing found in cache: do lookup to possibly add new objects to
593 X509_OBJECT
*xobj
= X509_OBJECT_new();
595 X509_STORE_unlock(store
);
599 if (!X509_STORE_CTX_get_by_subject(ctx
, X509_LU_X509
, nm
, xobj
)) {
600 X509_OBJECT_free(xobj
);
603 X509_OBJECT_free(xobj
);
604 X509_STORE_lock(store
);
605 idx
= x509_object_idx_cnt(store
->objs
, X509_LU_X509
, nm
, &cnt
);
607 X509_STORE_unlock(store
);
612 sk
= sk_X509_new_null();
613 for (i
= 0; i
< cnt
; i
++, idx
++) {
614 obj
= sk_X509_OBJECT_value(store
->objs
, idx
);
616 if (!X509_add_cert(sk
, x
, X509_ADD_FLAG_UP_REF
)) {
617 X509_STORE_unlock(store
);
618 sk_X509_pop_free(sk
, X509_free
);
622 X509_STORE_unlock(store
);
626 STACK_OF(X509_CRL
) *X509_STORE_CTX_get1_crls(const X509_STORE_CTX
*ctx
,
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
) == 0)
701 * Try to get issuer cert from |ctx->store| matching the subject name of |x|.
702 * Prefer the first non-expired one, else take the most recently expired one.
705 * 1 lookup successful.
706 * 0 certificate not found.
707 * -1 some other error.
709 int X509_STORE_CTX_get1_issuer(X509
**issuer
, X509_STORE_CTX
*ctx
, X509
*x
)
712 X509_OBJECT
*obj
= X509_OBJECT_new(), *pobj
= NULL
;
713 X509_STORE
*store
= ctx
->store
;
714 int i
, ok
, idx
, ret
, nmatch
= 0;
719 xn
= X509_get_issuer_name(x
);
720 ok
= X509_STORE_CTX_get_by_subject(ctx
, X509_LU_X509
, xn
, obj
);
722 X509_OBJECT_free(obj
);
725 /* If certificate matches and is currently valid all OK */
726 if (ctx
->check_issued(ctx
, x
, obj
->data
.x509
)) {
727 if (ossl_x509_check_cert_time(ctx
, obj
->data
.x509
, -1)) {
728 *issuer
= obj
->data
.x509
;
729 /* |*issuer| has taken over the cert reference from |obj| */
730 obj
->type
= X509_LU_NONE
;
731 X509_OBJECT_free(obj
);
735 X509_OBJECT_free(obj
);
738 * Due to limitations of the API this can only retrieve a single cert.
739 * However it will fill the cache with all matching certificates,
740 * so we can examine the cache for all matches.
745 /* Find index of first currently valid cert accepted by 'check_issued' */
747 X509_STORE_lock(store
);
748 idx
= x509_object_idx_cnt(store
->objs
, X509_LU_X509
, xn
, &nmatch
);
749 if (idx
!= -1) { /* should be true as we've had at least one match */
750 /* Look through all matching certs for suitable issuer */
751 for (i
= idx
; i
< idx
+ nmatch
; i
++) {
752 pobj
= sk_X509_OBJECT_value(store
->objs
, i
);
753 /* See if we've run past the matches */
754 if (pobj
->type
!= X509_LU_X509
)
756 if (ctx
->check_issued(ctx
, x
, pobj
->data
.x509
)) {
758 /* If times check fine, exit with match, else keep looking. */
759 if (ossl_x509_check_cert_time(ctx
, pobj
->data
.x509
, -1)) {
760 *issuer
= pobj
->data
.x509
;
764 * Leave the so far most recently expired match in *issuer
765 * so we return nearest match if no certificate time is OK.
768 || ASN1_TIME_compare(X509_get0_notAfter(pobj
->data
.x509
),
769 X509_get0_notAfter(*issuer
)) > 0)
770 *issuer
= pobj
->data
.x509
;
774 if (*issuer
!= NULL
&& !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
, const X509_VERIFY_PARAM
*param
)
805 return X509_VERIFY_PARAM_set1(ctx
->param
, param
);
808 X509_VERIFY_PARAM
*X509_STORE_get0_param(const 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(const 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(const 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(const 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(const 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(const 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(const 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(const 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(const 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(const 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(const 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(const 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(const 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(const X509_STORE
*ctx
, int idx
)
951 return CRYPTO_get_ex_data(&ctx
->ex_data
, idx
);
954 X509_STORE
*X509_STORE_CTX_get0_store(const X509_STORE_CTX
*ctx
)