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 if (!X509_up_ref(cert))
584 if (!sk_X509_push(sk, cert)) {
590 X509_STORE_unlock(store);
594 X509_STORE_unlock(store);
595 sk_X509_pop_free(sk, X509_free);
599 STACK_OF(X509) *X509_STORE_CTX_get1_certs(X509_STORE_CTX *ctx,
603 STACK_OF(X509) *sk = NULL;
606 X509_STORE *store = ctx->store;
611 X509_STORE_lock(store);
612 idx = x509_object_idx_cnt(store->objs, X509_LU_X509, nm, &cnt);
615 * Nothing found in cache: do lookup to possibly add new objects to
618 X509_OBJECT *xobj = X509_OBJECT_new();
620 X509_STORE_unlock(store);
624 if (!X509_STORE_CTX_get_by_subject(ctx, X509_LU_X509, nm, xobj)) {
625 X509_OBJECT_free(xobj);
628 X509_OBJECT_free(xobj);
629 X509_STORE_lock(store);
630 idx = x509_object_idx_cnt(store->objs, X509_LU_X509, nm, &cnt);
632 X509_STORE_unlock(store);
637 sk = sk_X509_new_null();
638 for (i = 0; i < cnt; i++, idx++) {
639 obj = sk_X509_OBJECT_value(store->objs, idx);
641 if (!X509_up_ref(x)) {
642 X509_STORE_unlock(store);
643 sk_X509_pop_free(sk, X509_free);
646 if (!sk_X509_push(sk, x)) {
647 X509_STORE_unlock(store);
649 sk_X509_pop_free(sk, X509_free);
653 X509_STORE_unlock(store);
657 STACK_OF(X509_CRL) *X509_STORE_CTX_get1_crls(const X509_STORE_CTX *ctx,
661 STACK_OF(X509_CRL) *sk = sk_X509_CRL_new_null();
663 X509_OBJECT *obj, *xobj = X509_OBJECT_new();
664 X509_STORE *store = ctx->store;
666 /* Always do lookup to possibly add new CRLs to cache */
670 || !X509_STORE_CTX_get_by_subject(ctx, X509_LU_CRL, nm, xobj)) {
671 X509_OBJECT_free(xobj);
672 sk_X509_CRL_free(sk);
675 X509_OBJECT_free(xobj);
676 X509_STORE_lock(store);
677 idx = x509_object_idx_cnt(store->objs, X509_LU_CRL, nm, &cnt);
679 X509_STORE_unlock(store);
680 sk_X509_CRL_free(sk);
684 for (i = 0; i < cnt; i++, idx++) {
685 obj = sk_X509_OBJECT_value(store->objs, idx);
687 if (!X509_CRL_up_ref(x)) {
688 X509_STORE_unlock(store);
689 sk_X509_CRL_pop_free(sk, X509_CRL_free);
692 if (!sk_X509_CRL_push(sk, x)) {
693 X509_STORE_unlock(store);
695 sk_X509_CRL_pop_free(sk, X509_CRL_free);
699 X509_STORE_unlock(store);
703 X509_OBJECT *X509_OBJECT_retrieve_match(STACK_OF(X509_OBJECT) *h,
709 idx = sk_X509_OBJECT_find(h, x);
712 if ((x->type != X509_LU_X509) && (x->type != X509_LU_CRL))
713 return sk_X509_OBJECT_value(h, idx);
714 for (i = idx, num = sk_X509_OBJECT_num(h); i < num; i++) {
715 obj = sk_X509_OBJECT_value(h, i);
716 if (x509_object_cmp((const X509_OBJECT **)&obj,
717 (const X509_OBJECT **)&x))
719 if (x->type == X509_LU_X509) {
720 if (!X509_cmp(obj->data.x509, x->data.x509))
722 } else if (x->type == X509_LU_CRL) {
723 if (!X509_CRL_match(obj->data.crl, x->data.crl))
732 * Try to get issuer certificate from store. Due to limitations
733 * of the API this can only retrieve a single certificate matching
734 * a given subject name. However it will fill the cache with all
735 * matching certificates, so we can examine the cache for all
739 * 1 lookup successful.
740 * 0 certificate not found.
741 * -1 some other error.
743 int X509_STORE_CTX_get1_issuer(X509 **issuer, X509_STORE_CTX *ctx, X509 *x)
746 X509_OBJECT *obj = X509_OBJECT_new(), *pobj = NULL;
747 X509_STORE *store = ctx->store;
753 xn = X509_get_issuer_name(x);
754 ok = X509_STORE_CTX_get_by_subject(ctx, X509_LU_X509, xn, obj);
756 X509_OBJECT_free(obj);
759 /* If certificate matches all OK */
760 if (ctx->check_issued(ctx, x, obj->data.x509)) {
761 if (x509_check_cert_time(ctx, obj->data.x509, -1)) {
762 *issuer = obj->data.x509;
763 if (!X509_up_ref(*issuer)) {
767 X509_OBJECT_free(obj);
771 X509_OBJECT_free(obj);
776 /* Else find index of first cert accepted by 'check_issued' */
778 X509_STORE_lock(store);
779 idx = X509_OBJECT_idx_by_subject(store->objs, X509_LU_X509, xn);
780 if (idx != -1) { /* should be true as we've had at least one
782 /* Look through all matching certs for suitable issuer */
783 for (i = idx; i < sk_X509_OBJECT_num(store->objs); i++) {
784 pobj = sk_X509_OBJECT_value(store->objs, i);
785 /* See if we've run past the matches */
786 if (pobj->type != X509_LU_X509)
788 if (X509_NAME_cmp(xn, X509_get_subject_name(pobj->data.x509)))
790 if (ctx->check_issued(ctx, x, pobj->data.x509)) {
791 *issuer = pobj->data.x509;
794 * If times check, exit with match,
795 * otherwise keep looking. Leave last
796 * match in issuer so we return nearest
797 * match if no certificate time is OK.
800 if (x509_check_cert_time(ctx, *issuer, -1))
805 if (*issuer && !X509_up_ref(*issuer)) {
809 X509_STORE_unlock(store);
813 int X509_STORE_set_flags(X509_STORE *ctx, unsigned long flags)
815 return X509_VERIFY_PARAM_set_flags(ctx->param, flags);
818 int X509_STORE_set_depth(X509_STORE *ctx, int depth)
820 X509_VERIFY_PARAM_set_depth(ctx->param, depth);
824 int X509_STORE_set_purpose(X509_STORE *ctx, int purpose)
826 return X509_VERIFY_PARAM_set_purpose(ctx->param, purpose);
829 int X509_STORE_set_trust(X509_STORE *ctx, int trust)
831 return X509_VERIFY_PARAM_set_trust(ctx->param, trust);
834 int X509_STORE_set1_param(X509_STORE *ctx, const X509_VERIFY_PARAM *param)
836 return X509_VERIFY_PARAM_set1(ctx->param, param);
839 X509_VERIFY_PARAM *X509_STORE_get0_param(const X509_STORE *ctx)
844 void X509_STORE_set_verify(X509_STORE *ctx, X509_STORE_CTX_verify_fn verify)
846 ctx->verify = verify;
849 X509_STORE_CTX_verify_fn X509_STORE_get_verify(const X509_STORE *ctx)
854 void X509_STORE_set_verify_cb(X509_STORE *ctx,
855 X509_STORE_CTX_verify_cb verify_cb)
857 ctx->verify_cb = verify_cb;
860 X509_STORE_CTX_verify_cb X509_STORE_get_verify_cb(const X509_STORE *ctx)
862 return ctx->verify_cb;
865 void X509_STORE_set_get_issuer(X509_STORE *ctx,
866 X509_STORE_CTX_get_issuer_fn get_issuer)
868 ctx->get_issuer = get_issuer;
871 X509_STORE_CTX_get_issuer_fn X509_STORE_get_get_issuer(const X509_STORE *ctx)
873 return ctx->get_issuer;
876 void X509_STORE_set_check_issued(X509_STORE *ctx,
877 X509_STORE_CTX_check_issued_fn check_issued)
879 ctx->check_issued = check_issued;
882 X509_STORE_CTX_check_issued_fn X509_STORE_get_check_issued(const X509_STORE *ctx)
884 return ctx->check_issued;
887 void X509_STORE_set_check_revocation(X509_STORE *ctx,
888 X509_STORE_CTX_check_revocation_fn check_revocation)
890 ctx->check_revocation = check_revocation;
893 X509_STORE_CTX_check_revocation_fn X509_STORE_get_check_revocation(const X509_STORE *ctx)
895 return ctx->check_revocation;
898 void X509_STORE_set_get_crl(X509_STORE *ctx,
899 X509_STORE_CTX_get_crl_fn get_crl)
901 ctx->get_crl = get_crl;
904 X509_STORE_CTX_get_crl_fn X509_STORE_get_get_crl(const X509_STORE *ctx)
909 void X509_STORE_set_check_crl(X509_STORE *ctx,
910 X509_STORE_CTX_check_crl_fn check_crl)
912 ctx->check_crl = check_crl;
915 X509_STORE_CTX_check_crl_fn X509_STORE_get_check_crl(const X509_STORE *ctx)
917 return ctx->check_crl;
920 void X509_STORE_set_cert_crl(X509_STORE *ctx,
921 X509_STORE_CTX_cert_crl_fn cert_crl)
923 ctx->cert_crl = cert_crl;
926 X509_STORE_CTX_cert_crl_fn X509_STORE_get_cert_crl(const X509_STORE *ctx)
928 return ctx->cert_crl;
931 void X509_STORE_set_check_policy(X509_STORE *ctx,
932 X509_STORE_CTX_check_policy_fn check_policy)
934 ctx->check_policy = check_policy;
937 X509_STORE_CTX_check_policy_fn X509_STORE_get_check_policy(const X509_STORE *ctx)
939 return ctx->check_policy;
942 void X509_STORE_set_lookup_certs(X509_STORE *ctx,
943 X509_STORE_CTX_lookup_certs_fn lookup_certs)
945 ctx->lookup_certs = lookup_certs;
948 X509_STORE_CTX_lookup_certs_fn X509_STORE_get_lookup_certs(const X509_STORE *ctx)
950 return ctx->lookup_certs;
953 void X509_STORE_set_lookup_crls(X509_STORE *ctx,
954 X509_STORE_CTX_lookup_crls_fn lookup_crls)
956 ctx->lookup_crls = lookup_crls;
959 X509_STORE_CTX_lookup_crls_fn X509_STORE_get_lookup_crls(const X509_STORE *ctx)
961 return ctx->lookup_crls;
964 void X509_STORE_set_cleanup(X509_STORE *ctx,
965 X509_STORE_CTX_cleanup_fn ctx_cleanup)
967 ctx->cleanup = ctx_cleanup;
970 X509_STORE_CTX_cleanup_fn X509_STORE_get_cleanup(const X509_STORE *ctx)
975 int X509_STORE_set_ex_data(X509_STORE *ctx, int idx, void *data)
977 return CRYPTO_set_ex_data(&ctx->ex_data, idx, data);
980 void *X509_STORE_get_ex_data(const X509_STORE *ctx, int idx)
982 return CRYPTO_get_ex_data(&ctx->ex_data, idx);
985 X509_STORE *X509_STORE_CTX_get0_store(const X509_STORE_CTX *ctx)