2 * Copyright 1995-2020 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 DEFINE_STACK_OF(X509_LOOKUP
)
19 DEFINE_STACK_OF(X509_OBJECT
)
20 DEFINE_STACK_OF(X509_CRL
)
23 X509_LOOKUP
*X509_LOOKUP_new(X509_LOOKUP_METHOD
*method
)
25 X509_LOOKUP
*ret
= OPENSSL_zalloc(sizeof(*ret
));
28 X509err(X509_F_X509_LOOKUP_NEW
, ERR_R_MALLOC_FAILURE
);
33 if (method
->new_item
!= NULL
&& method
->new_item(ret
) == 0) {
40 void X509_LOOKUP_free(X509_LOOKUP
*ctx
)
44 if ((ctx
->method
!= NULL
) && (ctx
->method
->free
!= NULL
))
45 (*ctx
->method
->free
) (ctx
);
49 int X509_STORE_lock(X509_STORE
*s
)
51 return CRYPTO_THREAD_write_lock(s
->lock
);
54 int X509_STORE_unlock(X509_STORE
*s
)
56 return CRYPTO_THREAD_unlock(s
->lock
);
59 int X509_LOOKUP_init(X509_LOOKUP
*ctx
)
61 if (ctx
->method
== NULL
)
63 if (ctx
->method
->init
!= NULL
)
64 return ctx
->method
->init(ctx
);
69 int X509_LOOKUP_shutdown(X509_LOOKUP
*ctx
)
71 if (ctx
->method
== NULL
)
73 if (ctx
->method
->shutdown
!= NULL
)
74 return ctx
->method
->shutdown(ctx
);
79 int X509_LOOKUP_ctrl_with_libctx(X509_LOOKUP
*ctx
, int cmd
, const char *argc
,
80 long argl
, char **ret
,
81 OPENSSL_CTX
*libctx
, const char *propq
)
83 if (ctx
->method
== NULL
)
85 if (ctx
->method
->ctrl_with_libctx
!= NULL
)
86 return ctx
->method
->ctrl_with_libctx(ctx
, cmd
, argc
, argl
, ret
,
88 if (ctx
->method
->ctrl
!= NULL
)
89 return ctx
->method
->ctrl(ctx
, cmd
, argc
, argl
, ret
);
93 int X509_LOOKUP_ctrl(X509_LOOKUP
*ctx
, int cmd
, const char *argc
, long argl
,
96 return X509_LOOKUP_ctrl_with_libctx(ctx
, cmd
, argc
, argl
, ret
, NULL
, NULL
);
99 int X509_LOOKUP_by_subject_with_libctx(X509_LOOKUP
*ctx
, X509_LOOKUP_TYPE type
,
100 const X509_NAME
*name
, X509_OBJECT
*ret
,
101 OPENSSL_CTX
*libctx
, const char *propq
)
104 || ctx
->method
== NULL
105 || (ctx
->method
->get_by_subject
== NULL
106 && ctx
->method
->get_by_subject_with_libctx
== NULL
))
108 if (ctx
->method
->get_by_subject_with_libctx
!= NULL
)
109 return ctx
->method
->get_by_subject_with_libctx(ctx
, type
, name
, ret
,
112 return ctx
->method
->get_by_subject(ctx
, type
, name
, ret
);
115 int X509_LOOKUP_by_subject(X509_LOOKUP
*ctx
, X509_LOOKUP_TYPE type
,
116 const X509_NAME
*name
, X509_OBJECT
*ret
)
118 return X509_LOOKUP_by_subject_with_libctx(ctx
, type
, name
, ret
, NULL
, NULL
);
121 int X509_LOOKUP_by_issuer_serial(X509_LOOKUP
*ctx
, X509_LOOKUP_TYPE type
,
122 const X509_NAME
*name
,
123 const ASN1_INTEGER
*serial
,
126 if ((ctx
->method
== NULL
) || (ctx
->method
->get_by_issuer_serial
== NULL
))
128 return ctx
->method
->get_by_issuer_serial(ctx
, type
, name
, serial
, ret
);
131 int X509_LOOKUP_by_fingerprint(X509_LOOKUP
*ctx
, X509_LOOKUP_TYPE type
,
132 const unsigned char *bytes
, int len
,
135 if ((ctx
->method
== NULL
) || (ctx
->method
->get_by_fingerprint
== NULL
))
137 return ctx
->method
->get_by_fingerprint(ctx
, type
, bytes
, len
, ret
);
140 int X509_LOOKUP_by_alias(X509_LOOKUP
*ctx
, X509_LOOKUP_TYPE type
,
141 const char *str
, int len
, X509_OBJECT
*ret
)
143 if ((ctx
->method
== NULL
) || (ctx
->method
->get_by_alias
== NULL
))
145 return ctx
->method
->get_by_alias(ctx
, type
, str
, len
, ret
);
148 int X509_LOOKUP_set_method_data(X509_LOOKUP
*ctx
, void *data
)
150 ctx
->method_data
= data
;
154 void *X509_LOOKUP_get_method_data(const X509_LOOKUP
*ctx
)
156 return ctx
->method_data
;
159 X509_STORE
*X509_LOOKUP_get_store(const X509_LOOKUP
*ctx
)
161 return ctx
->store_ctx
;
165 static int x509_object_cmp(const X509_OBJECT
*const *a
,
166 const X509_OBJECT
*const *b
)
170 ret
= ((*a
)->type
- (*b
)->type
);
173 switch ((*a
)->type
) {
175 ret
= X509_subject_name_cmp((*a
)->data
.x509
, (*b
)->data
.x509
);
178 ret
= X509_CRL_cmp((*a
)->data
.crl
, (*b
)->data
.crl
);
187 X509_STORE
*X509_STORE_new(void)
189 X509_STORE
*ret
= OPENSSL_zalloc(sizeof(*ret
));
192 X509err(0, ERR_R_MALLOC_FAILURE
);
195 if ((ret
->objs
= sk_X509_OBJECT_new(x509_object_cmp
)) == NULL
) {
196 X509err(0, ERR_R_MALLOC_FAILURE
);
200 if ((ret
->get_cert_methods
= sk_X509_LOOKUP_new_null()) == NULL
) {
201 X509err(0, ERR_R_MALLOC_FAILURE
);
205 if ((ret
->param
= X509_VERIFY_PARAM_new()) == NULL
) {
206 X509err(0, ERR_R_MALLOC_FAILURE
);
209 if (!CRYPTO_new_ex_data(CRYPTO_EX_INDEX_X509_STORE
, ret
, &ret
->ex_data
)) {
210 X509err(0, ERR_R_MALLOC_FAILURE
);
214 ret
->lock
= CRYPTO_THREAD_lock_new();
215 if (ret
->lock
== NULL
) {
216 X509err(0, ERR_R_MALLOC_FAILURE
);
223 X509_VERIFY_PARAM_free(ret
->param
);
224 sk_X509_OBJECT_free(ret
->objs
);
225 sk_X509_LOOKUP_free(ret
->get_cert_methods
);
230 void X509_STORE_free(X509_STORE
*vfy
)
233 STACK_OF(X509_LOOKUP
) *sk
;
238 CRYPTO_DOWN_REF(&vfy
->references
, &i
, vfy
->lock
);
239 REF_PRINT_COUNT("X509_STORE", vfy
);
242 REF_ASSERT_ISNT(i
< 0);
244 sk
= vfy
->get_cert_methods
;
245 for (i
= 0; i
< sk_X509_LOOKUP_num(sk
); i
++) {
246 lu
= sk_X509_LOOKUP_value(sk
, i
);
247 X509_LOOKUP_shutdown(lu
);
248 X509_LOOKUP_free(lu
);
250 sk_X509_LOOKUP_free(sk
);
251 sk_X509_OBJECT_pop_free(vfy
->objs
, X509_OBJECT_free
);
253 CRYPTO_free_ex_data(CRYPTO_EX_INDEX_X509_STORE
, vfy
, &vfy
->ex_data
);
254 X509_VERIFY_PARAM_free(vfy
->param
);
255 CRYPTO_THREAD_lock_free(vfy
->lock
);
259 int X509_STORE_up_ref(X509_STORE
*vfy
)
263 if (CRYPTO_UP_REF(&vfy
->references
, &i
, vfy
->lock
) <= 0)
266 REF_PRINT_COUNT("X509_STORE", vfy
);
267 REF_ASSERT_ISNT(i
< 2);
268 return ((i
> 1) ? 1 : 0);
271 X509_LOOKUP
*X509_STORE_add_lookup(X509_STORE
*v
, X509_LOOKUP_METHOD
*m
)
274 STACK_OF(X509_LOOKUP
) *sk
;
277 sk
= v
->get_cert_methods
;
278 for (i
= 0; i
< sk_X509_LOOKUP_num(sk
); i
++) {
279 lu
= sk_X509_LOOKUP_value(sk
, i
);
280 if (m
== lu
->method
) {
285 lu
= X509_LOOKUP_new(m
);
287 X509err(X509_F_X509_STORE_ADD_LOOKUP
, ERR_R_MALLOC_FAILURE
);
292 if (sk_X509_LOOKUP_push(v
->get_cert_methods
, lu
))
295 X509err(X509_F_X509_STORE_ADD_LOOKUP
, ERR_R_MALLOC_FAILURE
);
296 X509_LOOKUP_free(lu
);
300 X509_OBJECT
*X509_STORE_CTX_get_obj_by_subject(X509_STORE_CTX
*vs
,
301 X509_LOOKUP_TYPE type
,
302 const X509_NAME
*name
)
304 X509_OBJECT
*ret
= X509_OBJECT_new();
308 if (!X509_STORE_CTX_get_by_subject(vs
, type
, name
, ret
)) {
309 X509_OBJECT_free(ret
);
315 int X509_STORE_CTX_get_by_subject(const X509_STORE_CTX
*vs
,
316 X509_LOOKUP_TYPE type
,
317 const X509_NAME
*name
, X509_OBJECT
*ret
)
319 X509_STORE
*store
= vs
->store
;
321 X509_OBJECT stmp
, *tmp
;
327 stmp
.type
= X509_LU_NONE
;
328 stmp
.data
.ptr
= NULL
;
331 X509_STORE_lock(store
);
332 tmp
= X509_OBJECT_retrieve_by_subject(store
->objs
, type
, name
);
333 X509_STORE_unlock(store
);
335 if (tmp
== NULL
|| type
== X509_LU_CRL
) {
336 for (i
= 0; i
< sk_X509_LOOKUP_num(store
->get_cert_methods
); i
++) {
337 lu
= sk_X509_LOOKUP_value(store
->get_cert_methods
, i
);
338 j
= X509_LOOKUP_by_subject_with_libctx(lu
, type
, name
, &stmp
,
339 vs
->libctx
, vs
->propq
);
349 if (!X509_OBJECT_up_ref_count(tmp
))
352 ret
->type
= tmp
->type
;
353 ret
->data
.ptr
= tmp
->data
.ptr
;
358 static int x509_store_add(X509_STORE
*store
, void *x
, int crl
) {
360 int ret
= 0, added
= 0;
364 obj
= X509_OBJECT_new();
369 obj
->type
= X509_LU_CRL
;
370 obj
->data
.crl
= (X509_CRL
*)x
;
372 obj
->type
= X509_LU_X509
;
373 obj
->data
.x509
= (X509
*)x
;
375 if (!X509_OBJECT_up_ref_count(obj
)) {
376 obj
->type
= X509_LU_NONE
;
377 X509_OBJECT_free(obj
);
381 X509_STORE_lock(store
);
382 if (X509_OBJECT_retrieve_match(store
->objs
, obj
)) {
385 added
= sk_X509_OBJECT_push(store
->objs
, obj
);
388 X509_STORE_unlock(store
);
390 if (added
== 0) /* obj not pushed */
391 X509_OBJECT_free(obj
);
396 int X509_STORE_add_cert(X509_STORE
*ctx
, X509
*x
)
398 if (!x509_store_add(ctx
, x
, 0)) {
399 X509err(X509_F_X509_STORE_ADD_CERT
, ERR_R_MALLOC_FAILURE
);
405 int X509_STORE_add_crl(X509_STORE
*ctx
, X509_CRL
*x
)
407 if (!x509_store_add(ctx
, x
, 1)) {
408 X509err(X509_F_X509_STORE_ADD_CRL
, ERR_R_MALLOC_FAILURE
);
414 int X509_OBJECT_up_ref_count(X509_OBJECT
*a
)
420 return X509_up_ref(a
->data
.x509
);
422 return X509_CRL_up_ref(a
->data
.crl
);
427 X509
*X509_OBJECT_get0_X509(const X509_OBJECT
*a
)
429 if (a
== NULL
|| a
->type
!= X509_LU_X509
)
434 X509_CRL
*X509_OBJECT_get0_X509_CRL(const X509_OBJECT
*a
)
436 if (a
== NULL
|| a
->type
!= X509_LU_CRL
)
441 X509_LOOKUP_TYPE
X509_OBJECT_get_type(const X509_OBJECT
*a
)
446 X509_OBJECT
*X509_OBJECT_new(void)
448 X509_OBJECT
*ret
= OPENSSL_zalloc(sizeof(*ret
));
451 X509err(X509_F_X509_OBJECT_NEW
, ERR_R_MALLOC_FAILURE
);
454 ret
->type
= X509_LU_NONE
;
458 static void x509_object_free_internal(X509_OBJECT
*a
)
466 X509_free(a
->data
.x509
);
469 X509_CRL_free(a
->data
.crl
);
474 int X509_OBJECT_set1_X509(X509_OBJECT
*a
, X509
*obj
)
476 if (a
== NULL
|| !X509_up_ref(obj
))
479 x509_object_free_internal(a
);
480 a
->type
= X509_LU_X509
;
485 int X509_OBJECT_set1_X509_CRL(X509_OBJECT
*a
, X509_CRL
*obj
)
487 if (a
== NULL
|| !X509_CRL_up_ref(obj
))
490 x509_object_free_internal(a
);
491 a
->type
= X509_LU_CRL
;
496 void X509_OBJECT_free(X509_OBJECT
*a
)
498 x509_object_free_internal(a
);
502 static int x509_object_idx_cnt(STACK_OF(X509_OBJECT
) *h
, X509_LOOKUP_TYPE type
,
503 const X509_NAME
*name
, int *pnmatch
)
513 stmp
.data
.x509
= &x509_s
;
514 x509_s
.cert_info
.subject
= (X509_NAME
*)name
; /* won't modify it */
517 stmp
.data
.crl
= &crl_s
;
518 crl_s
.crl
.issuer
= (X509_NAME
*)name
; /* won't modify it */
525 idx
= sk_X509_OBJECT_find(h
, &stmp
);
526 if (idx
>= 0 && pnmatch
) {
528 const X509_OBJECT
*tobj
, *pstmp
;
531 for (tidx
= idx
+ 1; tidx
< sk_X509_OBJECT_num(h
); tidx
++) {
532 tobj
= sk_X509_OBJECT_value(h
, tidx
);
533 if (x509_object_cmp(&tobj
, &pstmp
))
541 int X509_OBJECT_idx_by_subject(STACK_OF(X509_OBJECT
) *h
, X509_LOOKUP_TYPE type
,
542 const X509_NAME
*name
)
544 return x509_object_idx_cnt(h
, type
, name
, NULL
);
547 X509_OBJECT
*X509_OBJECT_retrieve_by_subject(STACK_OF(X509_OBJECT
) *h
,
548 X509_LOOKUP_TYPE type
,
549 const X509_NAME
*name
)
552 idx
= X509_OBJECT_idx_by_subject(h
, type
, name
);
555 return sk_X509_OBJECT_value(h
, idx
);
558 STACK_OF(X509_OBJECT
) *X509_STORE_get0_objects(const X509_STORE
*v
)
563 /* TODO param type could be constified as change to lock is intermittent */
564 STACK_OF(X509
) *X509_STORE_get1_all_certs(X509_STORE
*store
)
567 STACK_OF(X509_OBJECT
) *objs
;
571 X509err(0, ERR_R_PASSED_NULL_PARAMETER
);
574 if ((sk
= sk_X509_new_null()) == NULL
)
576 X509_STORE_lock(store
);
577 objs
= X509_STORE_get0_objects(store
);
578 for (i
= 0; i
< sk_X509_OBJECT_num(objs
); i
++) {
579 X509
*cert
= X509_OBJECT_get0_X509(sk_X509_OBJECT_value(objs
, i
));
582 && !X509_add_cert(sk
, cert
, X509_ADD_FLAG_UP_REF
))
585 X509_STORE_unlock(store
);
589 X509_STORE_unlock(store
);
590 sk_X509_pop_free(sk
, X509_free
);
594 STACK_OF(X509
) *X509_STORE_CTX_get1_certs(X509_STORE_CTX
*ctx
,
598 STACK_OF(X509
) *sk
= NULL
;
601 X509_STORE
*store
= ctx
->store
;
606 X509_STORE_lock(store
);
607 idx
= x509_object_idx_cnt(store
->objs
, X509_LU_X509
, nm
, &cnt
);
610 * Nothing found in cache: do lookup to possibly add new objects to
613 X509_OBJECT
*xobj
= X509_OBJECT_new();
615 X509_STORE_unlock(store
);
619 if (!X509_STORE_CTX_get_by_subject(ctx
, X509_LU_X509
, nm
, xobj
)) {
620 X509_OBJECT_free(xobj
);
623 X509_OBJECT_free(xobj
);
624 X509_STORE_lock(store
);
625 idx
= x509_object_idx_cnt(store
->objs
, X509_LU_X509
, nm
, &cnt
);
627 X509_STORE_unlock(store
);
632 sk
= sk_X509_new_null();
633 for (i
= 0; i
< cnt
; i
++, idx
++) {
634 obj
= sk_X509_OBJECT_value(store
->objs
, idx
);
636 if (!X509_add_cert(sk
, x
, X509_ADD_FLAG_UP_REF
)) {
637 X509_STORE_unlock(store
);
638 sk_X509_pop_free(sk
, X509_free
);
642 X509_STORE_unlock(store
);
646 STACK_OF(X509_CRL
) *X509_STORE_CTX_get1_crls(const X509_STORE_CTX
*ctx
,
650 STACK_OF(X509_CRL
) *sk
= sk_X509_CRL_new_null();
652 X509_OBJECT
*obj
, *xobj
= X509_OBJECT_new();
653 X509_STORE
*store
= ctx
->store
;
655 /* Always do lookup to possibly add new CRLs to cache */
659 || !X509_STORE_CTX_get_by_subject(ctx
, X509_LU_CRL
, nm
, xobj
)) {
660 X509_OBJECT_free(xobj
);
661 sk_X509_CRL_free(sk
);
664 X509_OBJECT_free(xobj
);
665 X509_STORE_lock(store
);
666 idx
= x509_object_idx_cnt(store
->objs
, X509_LU_CRL
, nm
, &cnt
);
668 X509_STORE_unlock(store
);
669 sk_X509_CRL_free(sk
);
673 for (i
= 0; i
< cnt
; i
++, idx
++) {
674 obj
= sk_X509_OBJECT_value(store
->objs
, idx
);
676 if (!X509_CRL_up_ref(x
)) {
677 X509_STORE_unlock(store
);
678 sk_X509_CRL_pop_free(sk
, X509_CRL_free
);
681 if (!sk_X509_CRL_push(sk
, x
)) {
682 X509_STORE_unlock(store
);
684 sk_X509_CRL_pop_free(sk
, X509_CRL_free
);
688 X509_STORE_unlock(store
);
692 X509_OBJECT
*X509_OBJECT_retrieve_match(STACK_OF(X509_OBJECT
) *h
,
698 idx
= sk_X509_OBJECT_find(h
, x
);
701 if ((x
->type
!= X509_LU_X509
) && (x
->type
!= X509_LU_CRL
))
702 return sk_X509_OBJECT_value(h
, idx
);
703 for (i
= idx
, num
= sk_X509_OBJECT_num(h
); i
< num
; i
++) {
704 obj
= sk_X509_OBJECT_value(h
, i
);
705 if (x509_object_cmp((const X509_OBJECT
**)&obj
,
706 (const X509_OBJECT
**)&x
))
708 if (x
->type
== X509_LU_X509
) {
709 if (!X509_cmp(obj
->data
.x509
, x
->data
.x509
))
711 } else if (x
->type
== X509_LU_CRL
) {
712 if (!X509_CRL_match(obj
->data
.crl
, x
->data
.crl
))
721 * Try to get issuer certificate from store. Due to limitations
722 * of the API this can only retrieve a single certificate matching
723 * a given subject name. However it will fill the cache with all
724 * matching certificates, so we can examine the cache for all
728 * 1 lookup successful.
729 * 0 certificate not found.
730 * -1 some other error.
732 int X509_STORE_CTX_get1_issuer(X509
**issuer
, X509_STORE_CTX
*ctx
, X509
*x
)
735 X509_OBJECT
*obj
= X509_OBJECT_new(), *pobj
= NULL
;
736 X509_STORE
*store
= ctx
->store
;
742 xn
= X509_get_issuer_name(x
);
743 ok
= X509_STORE_CTX_get_by_subject(ctx
, X509_LU_X509
, xn
, obj
);
745 X509_OBJECT_free(obj
);
748 /* If certificate matches all OK */
749 if (ctx
->check_issued(ctx
, x
, obj
->data
.x509
)) {
750 if (x509_check_cert_time(ctx
, obj
->data
.x509
, -1)) {
751 *issuer
= obj
->data
.x509
;
752 if (!X509_up_ref(*issuer
)) {
756 X509_OBJECT_free(obj
);
760 X509_OBJECT_free(obj
);
765 /* Else find index of first cert accepted by 'check_issued' */
767 X509_STORE_lock(store
);
768 idx
= X509_OBJECT_idx_by_subject(store
->objs
, X509_LU_X509
, xn
);
769 if (idx
!= -1) { /* should be true as we've had at least one
771 /* Look through all matching certs for suitable issuer */
772 for (i
= idx
; i
< sk_X509_OBJECT_num(store
->objs
); i
++) {
773 pobj
= sk_X509_OBJECT_value(store
->objs
, i
);
774 /* See if we've run past the matches */
775 if (pobj
->type
!= X509_LU_X509
)
777 if (X509_NAME_cmp(xn
, X509_get_subject_name(pobj
->data
.x509
)))
779 if (ctx
->check_issued(ctx
, x
, pobj
->data
.x509
)) {
780 *issuer
= pobj
->data
.x509
;
783 * If times check, exit with match,
784 * otherwise keep looking. Leave last
785 * match in issuer so we return nearest
786 * match if no certificate time is OK.
789 if (x509_check_cert_time(ctx
, *issuer
, -1))
794 if (*issuer
&& !X509_up_ref(*issuer
)) {
798 X509_STORE_unlock(store
);
802 int X509_STORE_set_flags(X509_STORE
*ctx
, unsigned long flags
)
804 return X509_VERIFY_PARAM_set_flags(ctx
->param
, flags
);
807 int X509_STORE_set_depth(X509_STORE
*ctx
, int depth
)
809 X509_VERIFY_PARAM_set_depth(ctx
->param
, depth
);
813 int X509_STORE_set_purpose(X509_STORE
*ctx
, int purpose
)
815 return X509_VERIFY_PARAM_set_purpose(ctx
->param
, purpose
);
818 int X509_STORE_set_trust(X509_STORE
*ctx
, int trust
)
820 return X509_VERIFY_PARAM_set_trust(ctx
->param
, trust
);
823 int X509_STORE_set1_param(X509_STORE
*ctx
, const X509_VERIFY_PARAM
*param
)
825 return X509_VERIFY_PARAM_set1(ctx
->param
, param
);
828 X509_VERIFY_PARAM
*X509_STORE_get0_param(const X509_STORE
*ctx
)
833 void X509_STORE_set_verify(X509_STORE
*ctx
, X509_STORE_CTX_verify_fn verify
)
835 ctx
->verify
= verify
;
838 X509_STORE_CTX_verify_fn
X509_STORE_get_verify(const X509_STORE
*ctx
)
843 void X509_STORE_set_verify_cb(X509_STORE
*ctx
,
844 X509_STORE_CTX_verify_cb verify_cb
)
846 ctx
->verify_cb
= verify_cb
;
849 X509_STORE_CTX_verify_cb
X509_STORE_get_verify_cb(const X509_STORE
*ctx
)
851 return ctx
->verify_cb
;
854 void X509_STORE_set_get_issuer(X509_STORE
*ctx
,
855 X509_STORE_CTX_get_issuer_fn get_issuer
)
857 ctx
->get_issuer
= get_issuer
;
860 X509_STORE_CTX_get_issuer_fn
X509_STORE_get_get_issuer(const X509_STORE
*ctx
)
862 return ctx
->get_issuer
;
865 void X509_STORE_set_check_issued(X509_STORE
*ctx
,
866 X509_STORE_CTX_check_issued_fn check_issued
)
868 ctx
->check_issued
= check_issued
;
871 X509_STORE_CTX_check_issued_fn
X509_STORE_get_check_issued(const X509_STORE
*ctx
)
873 return ctx
->check_issued
;
876 void X509_STORE_set_check_revocation(X509_STORE
*ctx
,
877 X509_STORE_CTX_check_revocation_fn check_revocation
)
879 ctx
->check_revocation
= check_revocation
;
882 X509_STORE_CTX_check_revocation_fn
X509_STORE_get_check_revocation(const X509_STORE
*ctx
)
884 return ctx
->check_revocation
;
887 void X509_STORE_set_get_crl(X509_STORE
*ctx
,
888 X509_STORE_CTX_get_crl_fn get_crl
)
890 ctx
->get_crl
= get_crl
;
893 X509_STORE_CTX_get_crl_fn
X509_STORE_get_get_crl(const X509_STORE
*ctx
)
898 void X509_STORE_set_check_crl(X509_STORE
*ctx
,
899 X509_STORE_CTX_check_crl_fn check_crl
)
901 ctx
->check_crl
= check_crl
;
904 X509_STORE_CTX_check_crl_fn
X509_STORE_get_check_crl(const X509_STORE
*ctx
)
906 return ctx
->check_crl
;
909 void X509_STORE_set_cert_crl(X509_STORE
*ctx
,
910 X509_STORE_CTX_cert_crl_fn cert_crl
)
912 ctx
->cert_crl
= cert_crl
;
915 X509_STORE_CTX_cert_crl_fn
X509_STORE_get_cert_crl(const X509_STORE
*ctx
)
917 return ctx
->cert_crl
;
920 void X509_STORE_set_check_policy(X509_STORE
*ctx
,
921 X509_STORE_CTX_check_policy_fn check_policy
)
923 ctx
->check_policy
= check_policy
;
926 X509_STORE_CTX_check_policy_fn
X509_STORE_get_check_policy(const X509_STORE
*ctx
)
928 return ctx
->check_policy
;
931 void X509_STORE_set_lookup_certs(X509_STORE
*ctx
,
932 X509_STORE_CTX_lookup_certs_fn lookup_certs
)
934 ctx
->lookup_certs
= lookup_certs
;
937 X509_STORE_CTX_lookup_certs_fn
X509_STORE_get_lookup_certs(const X509_STORE
*ctx
)
939 return ctx
->lookup_certs
;
942 void X509_STORE_set_lookup_crls(X509_STORE
*ctx
,
943 X509_STORE_CTX_lookup_crls_fn lookup_crls
)
945 ctx
->lookup_crls
= lookup_crls
;
948 X509_STORE_CTX_lookup_crls_fn
X509_STORE_get_lookup_crls(const X509_STORE
*ctx
)
950 return ctx
->lookup_crls
;
953 void X509_STORE_set_cleanup(X509_STORE
*ctx
,
954 X509_STORE_CTX_cleanup_fn ctx_cleanup
)
956 ctx
->cleanup
= ctx_cleanup
;
959 X509_STORE_CTX_cleanup_fn
X509_STORE_get_cleanup(const X509_STORE
*ctx
)
964 int X509_STORE_set_ex_data(X509_STORE
*ctx
, int idx
, void *data
)
966 return CRYPTO_set_ex_data(&ctx
->ex_data
, idx
, data
);
969 void *X509_STORE_get_ex_data(const X509_STORE
*ctx
, int idx
)
971 return CRYPTO_get_ex_data(&ctx
->ex_data
, idx
);
974 X509_STORE
*X509_STORE_CTX_get0_store(const X509_STORE_CTX
*ctx
)