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)
21 X509_LOOKUP *X509_LOOKUP_new(X509_LOOKUP_METHOD *method)
23 X509_LOOKUP *ret = OPENSSL_zalloc(sizeof(*ret));
26 X509err(X509_F_X509_LOOKUP_NEW, ERR_R_MALLOC_FAILURE);
31 if (method->new_item != NULL && method->new_item(ret) == 0) {
38 void X509_LOOKUP_free(X509_LOOKUP *ctx)
42 if ((ctx->method != NULL) && (ctx->method->free != NULL))
43 (*ctx->method->free) (ctx);
47 int X509_STORE_lock(X509_STORE *s)
49 return CRYPTO_THREAD_write_lock(s->lock);
52 int X509_STORE_unlock(X509_STORE *s)
54 return CRYPTO_THREAD_unlock(s->lock);
57 int X509_LOOKUP_init(X509_LOOKUP *ctx)
59 if (ctx->method == NULL)
61 if (ctx->method->init != NULL)
62 return ctx->method->init(ctx);
67 int X509_LOOKUP_shutdown(X509_LOOKUP *ctx)
69 if (ctx->method == NULL)
71 if (ctx->method->shutdown != NULL)
72 return ctx->method->shutdown(ctx);
77 int X509_LOOKUP_ctrl_with_libctx(X509_LOOKUP *ctx, int cmd, const char *argc,
78 long argl, char **ret,
79 OPENSSL_CTX *libctx, const char *propq)
81 if (ctx->method == NULL)
83 if (ctx->method->ctrl_with_libctx != NULL)
84 return ctx->method->ctrl_with_libctx(ctx, cmd, argc, argl, ret,
86 if (ctx->method->ctrl != NULL)
87 return ctx->method->ctrl(ctx, cmd, argc, argl, ret);
91 int X509_LOOKUP_ctrl(X509_LOOKUP *ctx, int cmd, const char *argc, long argl,
94 return X509_LOOKUP_ctrl_with_libctx(ctx, cmd, argc, argl, ret, NULL, NULL);
97 int X509_LOOKUP_by_subject_with_libctx(X509_LOOKUP *ctx, X509_LOOKUP_TYPE type,
98 const X509_NAME *name, X509_OBJECT *ret,
99 OPENSSL_CTX *libctx, const char *propq)
102 || ctx->method == NULL
103 || (ctx->method->get_by_subject == NULL
104 && ctx->method->get_by_subject_with_libctx == NULL))
106 if (ctx->method->get_by_subject_with_libctx != NULL)
107 return ctx->method->get_by_subject_with_libctx(ctx, type, name, ret,
110 return ctx->method->get_by_subject(ctx, type, name, ret);
113 int X509_LOOKUP_by_subject(X509_LOOKUP *ctx, X509_LOOKUP_TYPE type,
114 const X509_NAME *name, X509_OBJECT *ret)
116 return X509_LOOKUP_by_subject_with_libctx(ctx, type, name, ret, NULL, NULL);
119 int X509_LOOKUP_by_issuer_serial(X509_LOOKUP *ctx, X509_LOOKUP_TYPE type,
120 const X509_NAME *name,
121 const ASN1_INTEGER *serial,
124 if ((ctx->method == NULL) || (ctx->method->get_by_issuer_serial == NULL))
126 return ctx->method->get_by_issuer_serial(ctx, type, name, serial, ret);
129 int X509_LOOKUP_by_fingerprint(X509_LOOKUP *ctx, X509_LOOKUP_TYPE type,
130 const unsigned char *bytes, int len,
133 if ((ctx->method == NULL) || (ctx->method->get_by_fingerprint == NULL))
135 return ctx->method->get_by_fingerprint(ctx, type, bytes, len, ret);
138 int X509_LOOKUP_by_alias(X509_LOOKUP *ctx, X509_LOOKUP_TYPE type,
139 const char *str, int len, X509_OBJECT *ret)
141 if ((ctx->method == NULL) || (ctx->method->get_by_alias == NULL))
143 return ctx->method->get_by_alias(ctx, type, str, len, ret);
146 int X509_LOOKUP_set_method_data(X509_LOOKUP *ctx, void *data)
148 ctx->method_data = data;
152 void *X509_LOOKUP_get_method_data(const X509_LOOKUP *ctx)
154 return ctx->method_data;
157 X509_STORE *X509_LOOKUP_get_store(const X509_LOOKUP *ctx)
159 return ctx->store_ctx;
163 static int x509_object_cmp(const X509_OBJECT *const *a,
164 const X509_OBJECT *const *b)
168 ret = ((*a)->type - (*b)->type);
171 switch ((*a)->type) {
173 ret = X509_subject_name_cmp((*a)->data.x509, (*b)->data.x509);
176 ret = X509_CRL_cmp((*a)->data.crl, (*b)->data.crl);
185 X509_STORE *X509_STORE_new(void)
187 X509_STORE *ret = OPENSSL_zalloc(sizeof(*ret));
190 X509err(0, ERR_R_MALLOC_FAILURE);
193 if ((ret->objs = sk_X509_OBJECT_new(x509_object_cmp)) == NULL) {
194 X509err(0, ERR_R_MALLOC_FAILURE);
198 if ((ret->get_cert_methods = sk_X509_LOOKUP_new_null()) == NULL) {
199 X509err(0, ERR_R_MALLOC_FAILURE);
203 if ((ret->param = X509_VERIFY_PARAM_new()) == NULL) {
204 X509err(0, ERR_R_MALLOC_FAILURE);
207 if (!CRYPTO_new_ex_data(CRYPTO_EX_INDEX_X509_STORE, ret, &ret->ex_data)) {
208 X509err(0, ERR_R_MALLOC_FAILURE);
212 ret->lock = CRYPTO_THREAD_lock_new();
213 if (ret->lock == NULL) {
214 X509err(0, ERR_R_MALLOC_FAILURE);
221 X509_VERIFY_PARAM_free(ret->param);
222 sk_X509_OBJECT_free(ret->objs);
223 sk_X509_LOOKUP_free(ret->get_cert_methods);
228 void X509_STORE_free(X509_STORE *vfy)
231 STACK_OF(X509_LOOKUP) *sk;
236 CRYPTO_DOWN_REF(&vfy->references, &i, vfy->lock);
237 REF_PRINT_COUNT("X509_STORE", vfy);
240 REF_ASSERT_ISNT(i < 0);
242 sk = vfy->get_cert_methods;
243 for (i = 0; i < sk_X509_LOOKUP_num(sk); i++) {
244 lu = sk_X509_LOOKUP_value(sk, i);
245 X509_LOOKUP_shutdown(lu);
246 X509_LOOKUP_free(lu);
248 sk_X509_LOOKUP_free(sk);
249 sk_X509_OBJECT_pop_free(vfy->objs, X509_OBJECT_free);
251 CRYPTO_free_ex_data(CRYPTO_EX_INDEX_X509_STORE, vfy, &vfy->ex_data);
252 X509_VERIFY_PARAM_free(vfy->param);
253 CRYPTO_THREAD_lock_free(vfy->lock);
257 int X509_STORE_up_ref(X509_STORE *vfy)
261 if (CRYPTO_UP_REF(&vfy->references, &i, vfy->lock) <= 0)
264 REF_PRINT_COUNT("X509_STORE", vfy);
265 REF_ASSERT_ISNT(i < 2);
266 return ((i > 1) ? 1 : 0);
269 X509_LOOKUP *X509_STORE_add_lookup(X509_STORE *v, X509_LOOKUP_METHOD *m)
272 STACK_OF(X509_LOOKUP) *sk;
275 sk = v->get_cert_methods;
276 for (i = 0; i < sk_X509_LOOKUP_num(sk); i++) {
277 lu = sk_X509_LOOKUP_value(sk, i);
278 if (m == lu->method) {
283 lu = X509_LOOKUP_new(m);
285 X509err(X509_F_X509_STORE_ADD_LOOKUP, ERR_R_MALLOC_FAILURE);
290 if (sk_X509_LOOKUP_push(v->get_cert_methods, lu))
293 X509err(X509_F_X509_STORE_ADD_LOOKUP, ERR_R_MALLOC_FAILURE);
294 X509_LOOKUP_free(lu);
298 X509_OBJECT *X509_STORE_CTX_get_obj_by_subject(X509_STORE_CTX *vs,
299 X509_LOOKUP_TYPE type,
300 const X509_NAME *name)
302 X509_OBJECT *ret = X509_OBJECT_new();
306 if (!X509_STORE_CTX_get_by_subject(vs, type, name, ret)) {
307 X509_OBJECT_free(ret);
313 int X509_STORE_CTX_get_by_subject(const X509_STORE_CTX *vs,
314 X509_LOOKUP_TYPE type,
315 const X509_NAME *name, X509_OBJECT *ret)
317 X509_STORE *store = vs->store;
319 X509_OBJECT stmp, *tmp;
325 stmp.type = X509_LU_NONE;
326 stmp.data.ptr = NULL;
329 X509_STORE_lock(store);
330 tmp = X509_OBJECT_retrieve_by_subject(store->objs, type, name);
331 X509_STORE_unlock(store);
333 if (tmp == NULL || type == X509_LU_CRL) {
334 for (i = 0; i < sk_X509_LOOKUP_num(store->get_cert_methods); i++) {
335 lu = sk_X509_LOOKUP_value(store->get_cert_methods, i);
336 j = X509_LOOKUP_by_subject_with_libctx(lu, type, name, &stmp,
337 vs->libctx, vs->propq);
347 if (!X509_OBJECT_up_ref_count(tmp))
350 ret->type = tmp->type;
351 ret->data.ptr = tmp->data.ptr;
356 static int x509_store_add(X509_STORE *store, void *x, int crl) {
358 int ret = 0, added = 0;
362 obj = X509_OBJECT_new();
367 obj->type = X509_LU_CRL;
368 obj->data.crl = (X509_CRL *)x;
370 obj->type = X509_LU_X509;
371 obj->data.x509 = (X509 *)x;
373 if (!X509_OBJECT_up_ref_count(obj)) {
374 obj->type = X509_LU_NONE;
375 X509_OBJECT_free(obj);
379 X509_STORE_lock(store);
380 if (X509_OBJECT_retrieve_match(store->objs, obj)) {
383 added = sk_X509_OBJECT_push(store->objs, obj);
386 X509_STORE_unlock(store);
388 if (added == 0) /* obj not pushed */
389 X509_OBJECT_free(obj);
394 int X509_STORE_add_cert(X509_STORE *ctx, X509 *x)
396 if (!x509_store_add(ctx, x, 0)) {
397 X509err(X509_F_X509_STORE_ADD_CERT, ERR_R_MALLOC_FAILURE);
403 int X509_STORE_add_crl(X509_STORE *ctx, X509_CRL *x)
405 if (!x509_store_add(ctx, x, 1)) {
406 X509err(X509_F_X509_STORE_ADD_CRL, ERR_R_MALLOC_FAILURE);
412 int X509_OBJECT_up_ref_count(X509_OBJECT *a)
418 return X509_up_ref(a->data.x509);
420 return X509_CRL_up_ref(a->data.crl);
425 X509 *X509_OBJECT_get0_X509(const X509_OBJECT *a)
427 if (a == NULL || a->type != X509_LU_X509)
432 X509_CRL *X509_OBJECT_get0_X509_CRL(const X509_OBJECT *a)
434 if (a == NULL || a->type != X509_LU_CRL)
439 X509_LOOKUP_TYPE X509_OBJECT_get_type(const X509_OBJECT *a)
444 X509_OBJECT *X509_OBJECT_new(void)
446 X509_OBJECT *ret = OPENSSL_zalloc(sizeof(*ret));
449 X509err(X509_F_X509_OBJECT_NEW, ERR_R_MALLOC_FAILURE);
452 ret->type = X509_LU_NONE;
456 static void x509_object_free_internal(X509_OBJECT *a)
464 X509_free(a->data.x509);
467 X509_CRL_free(a->data.crl);
472 int X509_OBJECT_set1_X509(X509_OBJECT *a, X509 *obj)
474 if (a == NULL || !X509_up_ref(obj))
477 x509_object_free_internal(a);
478 a->type = X509_LU_X509;
483 int X509_OBJECT_set1_X509_CRL(X509_OBJECT *a, X509_CRL *obj)
485 if (a == NULL || !X509_CRL_up_ref(obj))
488 x509_object_free_internal(a);
489 a->type = X509_LU_CRL;
494 void X509_OBJECT_free(X509_OBJECT *a)
496 x509_object_free_internal(a);
500 static int x509_object_idx_cnt(STACK_OF(X509_OBJECT) *h, X509_LOOKUP_TYPE type,
501 const X509_NAME *name, int *pnmatch)
511 stmp.data.x509 = &x509_s;
512 x509_s.cert_info.subject = (X509_NAME *)name; /* won't modify it */
515 stmp.data.crl = &crl_s;
516 crl_s.crl.issuer = (X509_NAME *)name; /* won't modify it */
523 idx = sk_X509_OBJECT_find(h, &stmp);
524 if (idx >= 0 && pnmatch) {
526 const X509_OBJECT *tobj, *pstmp;
529 for (tidx = idx + 1; tidx < sk_X509_OBJECT_num(h); tidx++) {
530 tobj = sk_X509_OBJECT_value(h, tidx);
531 if (x509_object_cmp(&tobj, &pstmp))
539 int X509_OBJECT_idx_by_subject(STACK_OF(X509_OBJECT) *h, X509_LOOKUP_TYPE type,
540 const X509_NAME *name)
542 return x509_object_idx_cnt(h, type, name, NULL);
545 X509_OBJECT *X509_OBJECT_retrieve_by_subject(STACK_OF(X509_OBJECT) *h,
546 X509_LOOKUP_TYPE type,
547 const X509_NAME *name)
550 idx = X509_OBJECT_idx_by_subject(h, type, name);
553 return sk_X509_OBJECT_value(h, idx);
556 STACK_OF(X509_OBJECT) *X509_STORE_get0_objects(const X509_STORE *v)
561 /* TODO param type could be constified as change to lock is intermittent */
562 STACK_OF(X509) *X509_STORE_get1_all_certs(X509_STORE *store)
565 STACK_OF(X509_OBJECT) *objs;
569 X509err(0, ERR_R_PASSED_NULL_PARAMETER);
572 if ((sk = sk_X509_new_null()) == NULL)
574 X509_STORE_lock(store);
575 objs = X509_STORE_get0_objects(store);
576 for (i = 0; i < sk_X509_OBJECT_num(objs); i++) {
577 X509 *cert = X509_OBJECT_get0_X509(sk_X509_OBJECT_value(objs, i));
580 && !X509_add_cert(sk, cert, X509_ADD_FLAG_UP_REF))
583 X509_STORE_unlock(store);
587 X509_STORE_unlock(store);
588 sk_X509_pop_free(sk, X509_free);
592 STACK_OF(X509) *X509_STORE_CTX_get1_certs(X509_STORE_CTX *ctx,
596 STACK_OF(X509) *sk = NULL;
599 X509_STORE *store = ctx->store;
604 X509_STORE_lock(store);
605 idx = x509_object_idx_cnt(store->objs, X509_LU_X509, nm, &cnt);
608 * Nothing found in cache: do lookup to possibly add new objects to
611 X509_OBJECT *xobj = X509_OBJECT_new();
613 X509_STORE_unlock(store);
617 if (!X509_STORE_CTX_get_by_subject(ctx, X509_LU_X509, nm, xobj)) {
618 X509_OBJECT_free(xobj);
621 X509_OBJECT_free(xobj);
622 X509_STORE_lock(store);
623 idx = x509_object_idx_cnt(store->objs, X509_LU_X509, nm, &cnt);
625 X509_STORE_unlock(store);
630 sk = sk_X509_new_null();
631 for (i = 0; i < cnt; i++, idx++) {
632 obj = sk_X509_OBJECT_value(store->objs, idx);
634 if (!X509_add_cert(sk, x, X509_ADD_FLAG_UP_REF)) {
635 X509_STORE_unlock(store);
636 sk_X509_pop_free(sk, X509_free);
640 X509_STORE_unlock(store);
644 STACK_OF(X509_CRL) *X509_STORE_CTX_get1_crls(const X509_STORE_CTX *ctx,
648 STACK_OF(X509_CRL) *sk = sk_X509_CRL_new_null();
650 X509_OBJECT *obj, *xobj = X509_OBJECT_new();
651 X509_STORE *store = ctx->store;
653 /* Always do lookup to possibly add new CRLs to cache */
657 || !X509_STORE_CTX_get_by_subject(ctx, X509_LU_CRL, nm, xobj)) {
658 X509_OBJECT_free(xobj);
659 sk_X509_CRL_free(sk);
662 X509_OBJECT_free(xobj);
663 X509_STORE_lock(store);
664 idx = x509_object_idx_cnt(store->objs, X509_LU_CRL, nm, &cnt);
666 X509_STORE_unlock(store);
667 sk_X509_CRL_free(sk);
671 for (i = 0; i < cnt; i++, idx++) {
672 obj = sk_X509_OBJECT_value(store->objs, idx);
674 if (!X509_CRL_up_ref(x)) {
675 X509_STORE_unlock(store);
676 sk_X509_CRL_pop_free(sk, X509_CRL_free);
679 if (!sk_X509_CRL_push(sk, x)) {
680 X509_STORE_unlock(store);
682 sk_X509_CRL_pop_free(sk, X509_CRL_free);
686 X509_STORE_unlock(store);
690 X509_OBJECT *X509_OBJECT_retrieve_match(STACK_OF(X509_OBJECT) *h,
696 idx = sk_X509_OBJECT_find(h, x);
699 if ((x->type != X509_LU_X509) && (x->type != X509_LU_CRL))
700 return sk_X509_OBJECT_value(h, idx);
701 for (i = idx, num = sk_X509_OBJECT_num(h); i < num; i++) {
702 obj = sk_X509_OBJECT_value(h, i);
703 if (x509_object_cmp((const X509_OBJECT **)&obj,
704 (const X509_OBJECT **)&x))
706 if (x->type == X509_LU_X509) {
707 if (!X509_cmp(obj->data.x509, x->data.x509))
709 } else if (x->type == X509_LU_CRL) {
710 if (!X509_CRL_match(obj->data.crl, x->data.crl))
719 * Try to get issuer certificate from store. Due to limitations
720 * of the API this can only retrieve a single certificate matching
721 * a given subject name. However it will fill the cache with all
722 * matching certificates, so we can examine the cache for all
726 * 1 lookup successful.
727 * 0 certificate not found.
728 * -1 some other error.
730 int X509_STORE_CTX_get1_issuer(X509 **issuer, X509_STORE_CTX *ctx, X509 *x)
733 X509_OBJECT *obj = X509_OBJECT_new(), *pobj = NULL;
734 X509_STORE *store = ctx->store;
740 xn = X509_get_issuer_name(x);
741 ok = X509_STORE_CTX_get_by_subject(ctx, X509_LU_X509, xn, obj);
743 X509_OBJECT_free(obj);
746 /* If certificate matches all OK */
747 if (ctx->check_issued(ctx, x, obj->data.x509)) {
748 if (x509_check_cert_time(ctx, obj->data.x509, -1)) {
749 *issuer = obj->data.x509;
750 if (!X509_up_ref(*issuer)) {
754 X509_OBJECT_free(obj);
758 X509_OBJECT_free(obj);
763 /* Else find index of first cert accepted by 'check_issued' */
765 X509_STORE_lock(store);
766 idx = X509_OBJECT_idx_by_subject(store->objs, X509_LU_X509, xn);
767 if (idx != -1) { /* should be true as we've had at least one
769 /* Look through all matching certs for suitable issuer */
770 for (i = idx; i < sk_X509_OBJECT_num(store->objs); i++) {
771 pobj = sk_X509_OBJECT_value(store->objs, i);
772 /* See if we've run past the matches */
773 if (pobj->type != X509_LU_X509)
775 if (X509_NAME_cmp(xn, X509_get_subject_name(pobj->data.x509)))
777 if (ctx->check_issued(ctx, x, pobj->data.x509)) {
778 *issuer = pobj->data.x509;
781 * If times check, exit with match,
782 * otherwise keep looking. Leave last
783 * match in issuer so we return nearest
784 * match if no certificate time is OK.
787 if (x509_check_cert_time(ctx, *issuer, -1))
792 if (*issuer && !X509_up_ref(*issuer)) {
796 X509_STORE_unlock(store);
800 int X509_STORE_set_flags(X509_STORE *ctx, unsigned long flags)
802 return X509_VERIFY_PARAM_set_flags(ctx->param, flags);
805 int X509_STORE_set_depth(X509_STORE *ctx, int depth)
807 X509_VERIFY_PARAM_set_depth(ctx->param, depth);
811 int X509_STORE_set_purpose(X509_STORE *ctx, int purpose)
813 return X509_VERIFY_PARAM_set_purpose(ctx->param, purpose);
816 int X509_STORE_set_trust(X509_STORE *ctx, int trust)
818 return X509_VERIFY_PARAM_set_trust(ctx->param, trust);
821 int X509_STORE_set1_param(X509_STORE *ctx, const X509_VERIFY_PARAM *param)
823 return X509_VERIFY_PARAM_set1(ctx->param, param);
826 X509_VERIFY_PARAM *X509_STORE_get0_param(const X509_STORE *ctx)
831 void X509_STORE_set_verify(X509_STORE *ctx, X509_STORE_CTX_verify_fn verify)
833 ctx->verify = verify;
836 X509_STORE_CTX_verify_fn X509_STORE_get_verify(const X509_STORE *ctx)
841 void X509_STORE_set_verify_cb(X509_STORE *ctx,
842 X509_STORE_CTX_verify_cb verify_cb)
844 ctx->verify_cb = verify_cb;
847 X509_STORE_CTX_verify_cb X509_STORE_get_verify_cb(const X509_STORE *ctx)
849 return ctx->verify_cb;
852 void X509_STORE_set_get_issuer(X509_STORE *ctx,
853 X509_STORE_CTX_get_issuer_fn get_issuer)
855 ctx->get_issuer = get_issuer;
858 X509_STORE_CTX_get_issuer_fn X509_STORE_get_get_issuer(const X509_STORE *ctx)
860 return ctx->get_issuer;
863 void X509_STORE_set_check_issued(X509_STORE *ctx,
864 X509_STORE_CTX_check_issued_fn check_issued)
866 ctx->check_issued = check_issued;
869 X509_STORE_CTX_check_issued_fn X509_STORE_get_check_issued(const X509_STORE *ctx)
871 return ctx->check_issued;
874 void X509_STORE_set_check_revocation(X509_STORE *ctx,
875 X509_STORE_CTX_check_revocation_fn check_revocation)
877 ctx->check_revocation = check_revocation;
880 X509_STORE_CTX_check_revocation_fn X509_STORE_get_check_revocation(const X509_STORE *ctx)
882 return ctx->check_revocation;
885 void X509_STORE_set_get_crl(X509_STORE *ctx,
886 X509_STORE_CTX_get_crl_fn get_crl)
888 ctx->get_crl = get_crl;
891 X509_STORE_CTX_get_crl_fn X509_STORE_get_get_crl(const X509_STORE *ctx)
896 void X509_STORE_set_check_crl(X509_STORE *ctx,
897 X509_STORE_CTX_check_crl_fn check_crl)
899 ctx->check_crl = check_crl;
902 X509_STORE_CTX_check_crl_fn X509_STORE_get_check_crl(const X509_STORE *ctx)
904 return ctx->check_crl;
907 void X509_STORE_set_cert_crl(X509_STORE *ctx,
908 X509_STORE_CTX_cert_crl_fn cert_crl)
910 ctx->cert_crl = cert_crl;
913 X509_STORE_CTX_cert_crl_fn X509_STORE_get_cert_crl(const X509_STORE *ctx)
915 return ctx->cert_crl;
918 void X509_STORE_set_check_policy(X509_STORE *ctx,
919 X509_STORE_CTX_check_policy_fn check_policy)
921 ctx->check_policy = check_policy;
924 X509_STORE_CTX_check_policy_fn X509_STORE_get_check_policy(const X509_STORE *ctx)
926 return ctx->check_policy;
929 void X509_STORE_set_lookup_certs(X509_STORE *ctx,
930 X509_STORE_CTX_lookup_certs_fn lookup_certs)
932 ctx->lookup_certs = lookup_certs;
935 X509_STORE_CTX_lookup_certs_fn X509_STORE_get_lookup_certs(const X509_STORE *ctx)
937 return ctx->lookup_certs;
940 void X509_STORE_set_lookup_crls(X509_STORE *ctx,
941 X509_STORE_CTX_lookup_crls_fn lookup_crls)
943 ctx->lookup_crls = lookup_crls;
946 X509_STORE_CTX_lookup_crls_fn X509_STORE_get_lookup_crls(const X509_STORE *ctx)
948 return ctx->lookup_crls;
951 void X509_STORE_set_cleanup(X509_STORE *ctx,
952 X509_STORE_CTX_cleanup_fn ctx_cleanup)
954 ctx->cleanup = ctx_cleanup;
957 X509_STORE_CTX_cleanup_fn X509_STORE_get_cleanup(const X509_STORE *ctx)
962 int X509_STORE_set_ex_data(X509_STORE *ctx, int idx, void *data)
964 return CRYPTO_set_ex_data(&ctx->ex_data, idx, data);
967 void *X509_STORE_get_ex_data(const X509_STORE *ctx, int idx)
969 return CRYPTO_get_ex_data(&ctx->ex_data, idx);
972 X509_STORE *X509_STORE_CTX_get0_store(const X509_STORE_CTX *ctx)