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 if (!X509_STORE_lock(store))
327 tmp = X509_OBJECT_retrieve_by_subject(store->objs, type, name);
328 X509_STORE_unlock(store);
330 if (tmp == NULL || type == X509_LU_CRL) {
331 for (i = 0; i < sk_X509_LOOKUP_num(store->get_cert_methods); i++) {
332 lu = sk_X509_LOOKUP_value(store->get_cert_methods, i);
333 j = X509_LOOKUP_by_subject_ex(lu, type, name, &stmp, vs->libctx,
344 if (!X509_OBJECT_up_ref_count(tmp))
347 ret->type = tmp->type;
348 ret->data.ptr = tmp->data.ptr;
353 static int x509_store_add(X509_STORE *store, void *x, int crl) {
355 int ret = 0, added = 0;
359 obj = X509_OBJECT_new();
364 obj->type = X509_LU_CRL;
365 obj->data.crl = (X509_CRL *)x;
367 obj->type = X509_LU_X509;
368 obj->data.x509 = (X509 *)x;
370 if (!X509_OBJECT_up_ref_count(obj)) {
371 obj->type = X509_LU_NONE;
372 X509_OBJECT_free(obj);
376 if (!X509_STORE_lock(store)) {
377 obj->type = X509_LU_NONE;
378 X509_OBJECT_free(obj);
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 ERR_raise(ERR_LIB_X509, 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 ERR_raise(ERR_LIB_X509, 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 ERR_raise(ERR_LIB_X509, 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_all(h, &stmp, pnmatch);
529 int X509_OBJECT_idx_by_subject(STACK_OF(X509_OBJECT) *h, X509_LOOKUP_TYPE type,
530 const X509_NAME *name)
532 return x509_object_idx_cnt(h, type, name, NULL);
535 X509_OBJECT *X509_OBJECT_retrieve_by_subject(STACK_OF(X509_OBJECT) *h,
536 X509_LOOKUP_TYPE type,
537 const X509_NAME *name)
540 idx = X509_OBJECT_idx_by_subject(h, type, name);
543 return sk_X509_OBJECT_value(h, idx);
546 STACK_OF(X509_OBJECT) *X509_STORE_get0_objects(const X509_STORE *v)
551 STACK_OF(X509) *X509_STORE_get1_all_certs(X509_STORE *store)
554 STACK_OF(X509_OBJECT) *objs;
558 ERR_raise(ERR_LIB_X509, ERR_R_PASSED_NULL_PARAMETER);
561 if ((sk = sk_X509_new_null()) == NULL)
563 if (!X509_STORE_lock(store))
566 objs = X509_STORE_get0_objects(store);
567 for (i = 0; i < sk_X509_OBJECT_num(objs); i++) {
568 X509 *cert = X509_OBJECT_get0_X509(sk_X509_OBJECT_value(objs, i));
571 && !X509_add_cert(sk, cert, X509_ADD_FLAG_UP_REF))
574 X509_STORE_unlock(store);
578 X509_STORE_unlock(store);
580 sk_X509_pop_free(sk, X509_free);
584 STACK_OF(X509) *X509_STORE_CTX_get1_certs(X509_STORE_CTX *ctx,
588 STACK_OF(X509) *sk = NULL;
591 X509_STORE *store = ctx->store;
596 if (!X509_STORE_lock(store))
599 idx = x509_object_idx_cnt(store->objs, X509_LU_X509, nm, &cnt);
602 * Nothing found in cache: do lookup to possibly add new objects to
605 X509_OBJECT *xobj = X509_OBJECT_new();
607 X509_STORE_unlock(store);
611 if (!X509_STORE_CTX_get_by_subject(ctx, X509_LU_X509, nm, xobj)) {
612 X509_OBJECT_free(xobj);
615 X509_OBJECT_free(xobj);
616 if (!X509_STORE_lock(store))
618 idx = x509_object_idx_cnt(store->objs, X509_LU_X509, nm, &cnt);
620 X509_STORE_unlock(store);
625 sk = sk_X509_new_null();
626 for (i = 0; i < cnt; i++, idx++) {
627 obj = sk_X509_OBJECT_value(store->objs, idx);
629 if (!X509_add_cert(sk, x, X509_ADD_FLAG_UP_REF)) {
630 X509_STORE_unlock(store);
631 sk_X509_pop_free(sk, X509_free);
635 X509_STORE_unlock(store);
639 STACK_OF(X509_CRL) *X509_STORE_CTX_get1_crls(const X509_STORE_CTX *ctx,
643 STACK_OF(X509_CRL) *sk = sk_X509_CRL_new_null();
645 X509_OBJECT *obj, *xobj = X509_OBJECT_new();
646 X509_STORE *store = ctx->store;
648 /* Always do lookup to possibly add new CRLs to cache */
652 || !X509_STORE_CTX_get_by_subject(ctx, X509_LU_CRL, nm, xobj)) {
653 X509_OBJECT_free(xobj);
654 sk_X509_CRL_free(sk);
657 X509_OBJECT_free(xobj);
658 if (!X509_STORE_lock(store)) {
659 sk_X509_CRL_free(sk);
662 idx = x509_object_idx_cnt(store->objs, X509_LU_CRL, nm, &cnt);
664 X509_STORE_unlock(store);
665 sk_X509_CRL_free(sk);
669 for (i = 0; i < cnt; i++, idx++) {
670 obj = sk_X509_OBJECT_value(store->objs, idx);
672 if (!X509_CRL_up_ref(x)) {
673 X509_STORE_unlock(store);
674 sk_X509_CRL_pop_free(sk, X509_CRL_free);
677 if (!sk_X509_CRL_push(sk, x)) {
678 X509_STORE_unlock(store);
680 sk_X509_CRL_pop_free(sk, X509_CRL_free);
684 X509_STORE_unlock(store);
688 X509_OBJECT *X509_OBJECT_retrieve_match(STACK_OF(X509_OBJECT) *h,
694 idx = sk_X509_OBJECT_find(h, x);
697 if ((x->type != X509_LU_X509) && (x->type != X509_LU_CRL))
698 return sk_X509_OBJECT_value(h, idx);
699 for (i = idx, num = sk_X509_OBJECT_num(h); i < num; i++) {
700 obj = sk_X509_OBJECT_value(h, i);
701 if (x509_object_cmp((const X509_OBJECT **)&obj,
702 (const X509_OBJECT **)&x))
704 if (x->type == X509_LU_X509) {
705 if (!X509_cmp(obj->data.x509, x->data.x509))
707 } else if (x->type == X509_LU_CRL) {
708 if (X509_CRL_match(obj->data.crl, x->data.crl) == 0)
717 * Try to get issuer cert from |ctx->store| matching the subject name of |x|.
718 * Prefer the first non-expired one, else take the most recently expired one.
721 * 1 lookup successful.
722 * 0 certificate not found.
723 * -1 some other error.
725 int X509_STORE_CTX_get1_issuer(X509 **issuer, X509_STORE_CTX *ctx, X509 *x)
728 X509_OBJECT *obj = X509_OBJECT_new(), *pobj = NULL;
729 X509_STORE *store = ctx->store;
730 int i, ok, idx, ret, nmatch = 0;
735 xn = X509_get_issuer_name(x);
736 ok = X509_STORE_CTX_get_by_subject(ctx, X509_LU_X509, xn, obj);
738 X509_OBJECT_free(obj);
741 /* If certificate matches and is currently valid all OK */
742 if (ctx->check_issued(ctx, x, obj->data.x509)) {
743 if (ossl_x509_check_cert_time(ctx, obj->data.x509, -1)) {
744 *issuer = obj->data.x509;
745 /* |*issuer| has taken over the cert reference from |obj| */
746 obj->type = X509_LU_NONE;
747 X509_OBJECT_free(obj);
751 X509_OBJECT_free(obj);
754 * Due to limitations of the API this can only retrieve a single cert.
755 * However it will fill the cache with all matching certificates,
756 * so we can examine the cache for all matches.
761 /* Find index of first currently valid cert accepted by 'check_issued' */
763 if (!X509_STORE_lock(store))
766 idx = x509_object_idx_cnt(store->objs, X509_LU_X509, xn, &nmatch);
767 if (idx != -1) { /* should be true as we've had at least one match */
768 /* Look through all matching certs for suitable issuer */
769 for (i = idx; i < idx + nmatch; i++) {
770 pobj = sk_X509_OBJECT_value(store->objs, i);
771 /* See if we've run past the matches */
772 if (pobj->type != X509_LU_X509)
774 if (ctx->check_issued(ctx, x, pobj->data.x509)) {
776 /* If times check fine, exit with match, else keep looking. */
777 if (ossl_x509_check_cert_time(ctx, pobj->data.x509, -1)) {
778 *issuer = pobj->data.x509;
782 * Leave the so far most recently expired match in *issuer
783 * so we return nearest match if no certificate time is OK.
786 || ASN1_TIME_compare(X509_get0_notAfter(pobj->data.x509),
787 X509_get0_notAfter(*issuer)) > 0)
788 *issuer = pobj->data.x509;
792 if (*issuer != NULL && !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)