2 * Copyright 1995-2024 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));
26 if (method->new_item != NULL && method->new_item(ret) == 0) {
33 void X509_LOOKUP_free(X509_LOOKUP *ctx)
37 if ((ctx->method != NULL) && (ctx->method->free != NULL))
38 (*ctx->method->free) (ctx);
42 int X509_STORE_lock(X509_STORE *xs)
44 return CRYPTO_THREAD_write_lock(xs->lock);
47 static int x509_store_read_lock(X509_STORE *xs)
49 return CRYPTO_THREAD_read_lock(xs->lock);
52 int X509_STORE_unlock(X509_STORE *xs)
54 return CRYPTO_THREAD_unlock(xs->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_ex(X509_LOOKUP *ctx, int cmd, const char *argc, long argl,
78 char **ret, OSSL_LIB_CTX *libctx, const char *propq)
80 if (ctx->method == NULL)
82 if (ctx->method->ctrl_ex != NULL)
83 return ctx->method->ctrl_ex(ctx, cmd, argc, argl, ret, libctx, propq);
84 if (ctx->method->ctrl != NULL)
85 return ctx->method->ctrl(ctx, cmd, argc, argl, ret);
89 int X509_LOOKUP_ctrl(X509_LOOKUP *ctx, int cmd, const char *argc, long argl,
92 return X509_LOOKUP_ctrl_ex(ctx, cmd, argc, argl, ret, NULL, NULL);
95 int X509_LOOKUP_by_subject_ex(X509_LOOKUP *ctx, X509_LOOKUP_TYPE type,
96 const X509_NAME *name, X509_OBJECT *ret,
97 OSSL_LIB_CTX *libctx, const char *propq)
100 || ctx->method == NULL
101 || (ctx->method->get_by_subject == NULL
102 && ctx->method->get_by_subject_ex == NULL))
104 if (ctx->method->get_by_subject_ex != NULL)
105 return ctx->method->get_by_subject_ex(ctx, type, name, ret, libctx,
108 return ctx->method->get_by_subject(ctx, type, name, ret);
111 int X509_LOOKUP_by_subject(X509_LOOKUP *ctx, X509_LOOKUP_TYPE type,
112 const X509_NAME *name, X509_OBJECT *ret)
114 return X509_LOOKUP_by_subject_ex(ctx, type, name, ret, NULL, NULL);
117 int X509_LOOKUP_by_issuer_serial(X509_LOOKUP *ctx, X509_LOOKUP_TYPE type,
118 const X509_NAME *name,
119 const ASN1_INTEGER *serial,
122 if ((ctx->method == NULL) || (ctx->method->get_by_issuer_serial == NULL))
124 return ctx->method->get_by_issuer_serial(ctx, type, name, serial, ret);
127 int X509_LOOKUP_by_fingerprint(X509_LOOKUP *ctx, X509_LOOKUP_TYPE type,
128 const unsigned char *bytes, int len,
131 if ((ctx->method == NULL) || (ctx->method->get_by_fingerprint == NULL))
133 return ctx->method->get_by_fingerprint(ctx, type, bytes, len, ret);
136 int X509_LOOKUP_by_alias(X509_LOOKUP *ctx, X509_LOOKUP_TYPE type,
137 const char *str, int len, X509_OBJECT *ret)
139 if ((ctx->method == NULL) || (ctx->method->get_by_alias == NULL))
141 return ctx->method->get_by_alias(ctx, type, str, len, ret);
144 int X509_LOOKUP_set_method_data(X509_LOOKUP *ctx, void *data)
146 ctx->method_data = data;
150 void *X509_LOOKUP_get_method_data(const X509_LOOKUP *ctx)
152 return ctx->method_data;
155 X509_STORE *X509_LOOKUP_get_store(const X509_LOOKUP *ctx)
157 return ctx->store_ctx;
160 static int x509_object_cmp(const X509_OBJECT *const *a,
161 const X509_OBJECT *const *b)
165 ret = ((*a)->type - (*b)->type);
168 switch ((*a)->type) {
170 ret = X509_subject_name_cmp((*a)->data.x509, (*b)->data.x509);
173 ret = X509_CRL_cmp((*a)->data.crl, (*b)->data.crl);
182 X509_STORE *X509_STORE_new(void)
184 X509_STORE *ret = OPENSSL_zalloc(sizeof(*ret));
188 if ((ret->objs = sk_X509_OBJECT_new(x509_object_cmp)) == NULL) {
189 ERR_raise(ERR_LIB_X509, ERR_R_CRYPTO_LIB);
193 if ((ret->get_cert_methods = sk_X509_LOOKUP_new_null()) == NULL) {
194 ERR_raise(ERR_LIB_X509, ERR_R_CRYPTO_LIB);
198 if ((ret->param = X509_VERIFY_PARAM_new()) == NULL) {
199 ERR_raise(ERR_LIB_X509, ERR_R_X509_LIB);
202 if (!CRYPTO_new_ex_data(CRYPTO_EX_INDEX_X509_STORE, ret, &ret->ex_data)) {
203 ERR_raise(ERR_LIB_X509, ERR_R_CRYPTO_LIB);
207 ret->lock = CRYPTO_THREAD_lock_new();
208 if (ret->lock == NULL) {
209 ERR_raise(ERR_LIB_X509, ERR_R_CRYPTO_LIB);
213 if (!CRYPTO_NEW_REF(&ret->references, 1))
218 X509_VERIFY_PARAM_free(ret->param);
219 sk_X509_OBJECT_free(ret->objs);
220 sk_X509_LOOKUP_free(ret->get_cert_methods);
221 CRYPTO_THREAD_lock_free(ret->lock);
226 void X509_STORE_free(X509_STORE *xs)
229 STACK_OF(X509_LOOKUP) *sk;
234 CRYPTO_DOWN_REF(&xs->references, &i);
235 REF_PRINT_COUNT("X509_STORE", xs);
238 REF_ASSERT_ISNT(i < 0);
240 sk = xs->get_cert_methods;
241 for (i = 0; i < sk_X509_LOOKUP_num(sk); i++) {
242 lu = sk_X509_LOOKUP_value(sk, i);
243 X509_LOOKUP_shutdown(lu);
244 X509_LOOKUP_free(lu);
246 sk_X509_LOOKUP_free(sk);
247 sk_X509_OBJECT_pop_free(xs->objs, X509_OBJECT_free);
249 CRYPTO_free_ex_data(CRYPTO_EX_INDEX_X509_STORE, xs, &xs->ex_data);
250 X509_VERIFY_PARAM_free(xs->param);
251 CRYPTO_THREAD_lock_free(xs->lock);
252 CRYPTO_FREE_REF(&xs->references);
256 int X509_STORE_up_ref(X509_STORE *xs)
260 if (CRYPTO_UP_REF(&xs->references, &i) <= 0)
263 REF_PRINT_COUNT("X509_STORE", xs);
264 REF_ASSERT_ISNT(i < 2);
265 return i > 1 ? 1 : 0;
268 X509_LOOKUP *X509_STORE_add_lookup(X509_STORE *xs, X509_LOOKUP_METHOD *m)
271 STACK_OF(X509_LOOKUP) *sk;
274 sk = xs->get_cert_methods;
275 for (i = 0; i < sk_X509_LOOKUP_num(sk); i++) {
276 lu = sk_X509_LOOKUP_value(sk, i);
277 if (m == lu->method) {
282 lu = X509_LOOKUP_new(m);
284 ERR_raise(ERR_LIB_X509, ERR_R_X509_LIB);
289 if (sk_X509_LOOKUP_push(xs->get_cert_methods, lu))
291 /* sk_X509_LOOKUP_push() failed */
292 ERR_raise(ERR_LIB_X509, ERR_R_CRYPTO_LIB);
293 X509_LOOKUP_free(lu);
297 /* Also fill the cache (ctx->store->objs) with all matching certificates. */
298 X509_OBJECT *X509_STORE_CTX_get_obj_by_subject(X509_STORE_CTX *ctx,
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(ctx, type, name, ret)) {
307 X509_OBJECT_free(ret);
314 * May be called with |ret| == NULL just for the side effect of
315 * caching all certs matching the given subject DN in |ctx->store->objs|.
316 * Returns 1 if successful,
317 * 0 if not found or X509_LOOKUP_by_subject_ex() returns an error,
320 static int ossl_x509_store_ctx_get_by_subject(const X509_STORE_CTX *ctx,
321 X509_LOOKUP_TYPE type,
322 const X509_NAME *name,
325 X509_STORE *store = ctx->store;
327 X509_OBJECT stmp, *tmp;
333 stmp.type = X509_LU_NONE;
334 stmp.data.ptr = NULL;
336 if (!x509_store_read_lock(store))
338 /* Should already be sorted...but just in case */
339 if (!sk_X509_OBJECT_is_sorted(store->objs)) {
340 X509_STORE_unlock(store);
341 /* Take a write lock instead of a read lock */
342 if (!X509_STORE_lock(store))
345 * Another thread might have sorted it in the meantime. But if so,
346 * sk_X509_OBJECT_sort() exits early.
348 sk_X509_OBJECT_sort(store->objs);
350 tmp = X509_OBJECT_retrieve_by_subject(store->objs, type, name);
351 X509_STORE_unlock(store);
353 if (tmp == NULL || type == X509_LU_CRL) {
354 for (i = 0; i < sk_X509_LOOKUP_num(store->get_cert_methods); i++) {
355 lu = sk_X509_LOOKUP_value(store->get_cert_methods, i);
358 if (lu->method == NULL)
360 j = X509_LOOKUP_by_subject_ex(lu, type, name, &stmp,
361 ctx->libctx, ctx->propq);
362 if (j != 0) { /* non-zero value is considered success here */
370 if (!X509_OBJECT_up_ref_count(tmp))
373 ret->type = tmp->type;
374 ret->data.ptr = tmp->data.ptr;
378 /* Also fill the cache |ctx->store->objs| with all matching certificates. */
379 int X509_STORE_CTX_get_by_subject(const X509_STORE_CTX *ctx,
380 X509_LOOKUP_TYPE type,
381 const X509_NAME *name, X509_OBJECT *ret)
383 return ossl_x509_store_ctx_get_by_subject(ctx, type, name, ret) > 0;
386 static int x509_store_add(X509_STORE *store, void *x, int crl)
389 int ret = 0, added = 0;
393 obj = X509_OBJECT_new();
398 obj->type = X509_LU_CRL;
399 obj->data.crl = (X509_CRL *)x;
401 obj->type = X509_LU_X509;
402 obj->data.x509 = (X509 *)x;
404 if (!X509_OBJECT_up_ref_count(obj)) {
405 obj->type = X509_LU_NONE;
406 X509_OBJECT_free(obj);
410 if (!X509_STORE_lock(store)) {
411 obj->type = X509_LU_NONE;
412 X509_OBJECT_free(obj);
416 if (X509_OBJECT_retrieve_match(store->objs, obj)) {
419 added = sk_X509_OBJECT_push(store->objs, obj);
422 X509_STORE_unlock(store);
424 if (added == 0) /* obj not pushed */
425 X509_OBJECT_free(obj);
430 int X509_STORE_add_cert(X509_STORE *xs, X509 *x)
432 if (!x509_store_add(xs, x, 0)) {
433 ERR_raise(ERR_LIB_X509, ERR_R_X509_LIB);
439 int X509_STORE_add_crl(X509_STORE *xs, X509_CRL *x)
441 if (!x509_store_add(xs, x, 1)) {
442 ERR_raise(ERR_LIB_X509, ERR_R_X509_LIB);
448 int X509_OBJECT_up_ref_count(X509_OBJECT *a)
454 return X509_up_ref(a->data.x509);
456 return X509_CRL_up_ref(a->data.crl);
461 X509 *X509_OBJECT_get0_X509(const X509_OBJECT *a)
463 if (a == NULL || a->type != X509_LU_X509)
468 X509_CRL *X509_OBJECT_get0_X509_CRL(const X509_OBJECT *a)
470 if (a == NULL || a->type != X509_LU_CRL)
475 X509_LOOKUP_TYPE X509_OBJECT_get_type(const X509_OBJECT *a)
480 X509_OBJECT *X509_OBJECT_new(void)
482 X509_OBJECT *ret = OPENSSL_zalloc(sizeof(*ret));
486 ret->type = X509_LU_NONE;
490 static void x509_object_free_internal(X509_OBJECT *a)
498 X509_free(a->data.x509);
501 X509_CRL_free(a->data.crl);
506 int X509_OBJECT_set1_X509(X509_OBJECT *a, X509 *obj)
508 if (a == NULL || !X509_up_ref(obj))
511 x509_object_free_internal(a);
512 a->type = X509_LU_X509;
517 int X509_OBJECT_set1_X509_CRL(X509_OBJECT *a, X509_CRL *obj)
519 if (a == NULL || !X509_CRL_up_ref(obj))
522 x509_object_free_internal(a);
523 a->type = X509_LU_CRL;
528 void X509_OBJECT_free(X509_OBJECT *a)
530 x509_object_free_internal(a);
534 /* Returns -1 if not found, but also on error */
535 static int x509_object_idx_cnt(STACK_OF(X509_OBJECT) *h, X509_LOOKUP_TYPE type,
536 const X509_NAME *name, int *pnmatch)
545 stmp.data.x509 = &x509_s;
546 x509_s.cert_info.subject = (X509_NAME *)name; /* won't modify it */
549 stmp.data.crl = &crl_s;
550 crl_s.crl.issuer = (X509_NAME *)name; /* won't modify it */
558 /* Assumes h is locked for read if applicable */
559 return sk_X509_OBJECT_find_all(h, &stmp, pnmatch);
562 /* Assumes h is locked for read if applicable */
563 int X509_OBJECT_idx_by_subject(STACK_OF(X509_OBJECT) *h, X509_LOOKUP_TYPE type,
564 const X509_NAME *name)
566 return x509_object_idx_cnt(h, type, name, NULL);
569 /* Assumes h is locked for read if applicable */
570 X509_OBJECT *X509_OBJECT_retrieve_by_subject(STACK_OF(X509_OBJECT) *h,
571 X509_LOOKUP_TYPE type,
572 const X509_NAME *name)
574 int idx = X509_OBJECT_idx_by_subject(h, type, name);
578 return sk_X509_OBJECT_value(h, idx);
581 STACK_OF(X509_OBJECT) *X509_STORE_get0_objects(const X509_STORE *xs)
586 static X509_OBJECT *x509_object_dup(const X509_OBJECT *obj)
588 X509_OBJECT *ret = X509_OBJECT_new();
592 ret->type = obj->type;
593 ret->data = obj->data;
594 X509_OBJECT_up_ref_count(ret);
598 STACK_OF(X509_OBJECT) *X509_STORE_get1_objects(X509_STORE *store)
600 STACK_OF(X509_OBJECT) *objs;
603 ERR_raise(ERR_LIB_X509, ERR_R_PASSED_NULL_PARAMETER);
607 if (!x509_store_read_lock(store))
610 objs = sk_X509_OBJECT_deep_copy(store->objs, x509_object_dup,
612 X509_STORE_unlock(store);
616 STACK_OF(X509) *X509_STORE_get1_all_certs(X509_STORE *store)
619 STACK_OF(X509_OBJECT) *objs;
623 ERR_raise(ERR_LIB_X509, ERR_R_PASSED_NULL_PARAMETER);
626 if ((sk = sk_X509_new_null()) == NULL)
628 if (!X509_STORE_lock(store))
631 sk_X509_OBJECT_sort(store->objs);
632 objs = X509_STORE_get0_objects(store);
633 for (i = 0; i < sk_X509_OBJECT_num(objs); i++) {
634 X509 *cert = X509_OBJECT_get0_X509(sk_X509_OBJECT_value(objs, i));
637 && !X509_add_cert(sk, cert, X509_ADD_FLAG_UP_REF))
640 X509_STORE_unlock(store);
644 X509_STORE_unlock(store);
646 OSSL_STACK_OF_X509_free(sk);
650 /* Returns NULL on internal/fatal error, empty stack if not found */
651 STACK_OF(X509) *X509_STORE_CTX_get1_certs(X509_STORE_CTX *ctx,
655 STACK_OF(X509) *sk = NULL;
658 X509_STORE *store = ctx->store;
661 return sk_X509_new_null();
663 if (!X509_STORE_lock(store))
666 sk_X509_OBJECT_sort(store->objs);
667 idx = x509_object_idx_cnt(store->objs, X509_LU_X509, nm, &cnt);
670 * Nothing found in cache: do lookup to possibly add new objects to
673 X509_OBJECT *xobj = X509_OBJECT_new();
675 X509_STORE_unlock(store);
678 i = ossl_x509_store_ctx_get_by_subject(ctx, X509_LU_X509, nm, xobj);
680 X509_OBJECT_free(xobj);
681 return i < 0 ? NULL : sk_X509_new_null();
683 X509_OBJECT_free(xobj);
684 if (!X509_STORE_lock(store))
686 sk_X509_OBJECT_sort(store->objs);
687 idx = x509_object_idx_cnt(store->objs, X509_LU_X509, nm, &cnt);
689 sk = sk_X509_new_null();
694 sk = sk_X509_new_null();
697 for (i = 0; i < cnt; i++, idx++) {
698 obj = sk_X509_OBJECT_value(store->objs, idx);
700 if (!X509_add_cert(sk, x, X509_ADD_FLAG_UP_REF)) {
701 X509_STORE_unlock(store);
702 OSSL_STACK_OF_X509_free(sk);
707 X509_STORE_unlock(store);
711 /* Returns NULL on internal/fatal error, empty stack if not found */
712 STACK_OF(X509_CRL) *X509_STORE_CTX_get1_crls(const X509_STORE_CTX *ctx,
716 STACK_OF(X509_CRL) *sk = sk_X509_CRL_new_null();
718 X509_OBJECT *obj, *xobj = X509_OBJECT_new();
719 X509_STORE *store = ctx->store;
721 /* Always do lookup to possibly add new CRLs to cache */
724 || (i = ossl_x509_store_ctx_get_by_subject(ctx, X509_LU_CRL,
726 X509_OBJECT_free(xobj);
727 sk_X509_CRL_free(sk);
730 X509_OBJECT_free(xobj);
733 if (!X509_STORE_lock(store)) {
734 sk_X509_CRL_free(sk);
737 sk_X509_OBJECT_sort(store->objs);
738 idx = x509_object_idx_cnt(store->objs, X509_LU_CRL, nm, &cnt);
740 X509_STORE_unlock(store);
744 for (i = 0; i < cnt; i++, idx++) {
745 obj = sk_X509_OBJECT_value(store->objs, idx);
747 if (!X509_CRL_up_ref(x)) {
748 X509_STORE_unlock(store);
749 sk_X509_CRL_pop_free(sk, X509_CRL_free);
752 if (!sk_X509_CRL_push(sk, x)) {
753 X509_STORE_unlock(store);
755 sk_X509_CRL_pop_free(sk, X509_CRL_free);
759 X509_STORE_unlock(store);
763 X509_OBJECT *X509_OBJECT_retrieve_match(STACK_OF(X509_OBJECT) *h,
769 idx = sk_X509_OBJECT_find(h, x);
772 if ((x->type != X509_LU_X509) && (x->type != X509_LU_CRL))
773 return sk_X509_OBJECT_value(h, idx);
774 for (i = idx, num = sk_X509_OBJECT_num(h); i < num; i++) {
775 obj = sk_X509_OBJECT_value(h, i);
776 if (x509_object_cmp((const X509_OBJECT **)&obj,
777 (const X509_OBJECT **)&x))
779 if (x->type == X509_LU_X509) {
780 if (!X509_cmp(obj->data.x509, x->data.x509))
782 } else if (x->type == X509_LU_CRL) {
783 if (X509_CRL_match(obj->data.crl, x->data.crl) == 0)
793 * Try to get issuer cert from |ctx->store| matching the subject name of |x|.
794 * Prefer the first non-expired one, else take the most recently expired one.
797 * 1 lookup successful.
798 * 0 certificate not found.
799 * -1 some other error.
801 int X509_STORE_CTX_get1_issuer(X509 **issuer, X509_STORE_CTX *ctx, X509 *x)
804 X509_OBJECT *obj = X509_OBJECT_new(), *pobj = NULL;
805 X509_STORE *store = ctx->store;
806 int i, ok, idx, ret, nmatch = 0;
811 xn = X509_get_issuer_name(x);
812 ok = ossl_x509_store_ctx_get_by_subject(ctx, X509_LU_X509, xn, obj);
814 X509_OBJECT_free(obj);
817 /* If certificate matches and is currently valid all OK */
818 if (ctx->check_issued(ctx, x, obj->data.x509)) {
819 if (ossl_x509_check_cert_time(ctx, obj->data.x509, -1)) {
820 *issuer = obj->data.x509;
821 /* |*issuer| has taken over the cert reference from |obj| */
822 obj->type = X509_LU_NONE;
823 X509_OBJECT_free(obj);
827 X509_OBJECT_free(obj);
830 * Due to limitations of the API this can only retrieve a single cert.
831 * However it will fill the cache with all matching certificates,
832 * so we can examine the cache for all matches.
837 /* Find index of first currently valid cert accepted by 'check_issued' */
839 if (!X509_STORE_lock(store))
842 sk_X509_OBJECT_sort(store->objs);
843 idx = x509_object_idx_cnt(store->objs, X509_LU_X509, xn, &nmatch);
844 if (idx != -1) { /* should be true as we've had at least one match */
845 /* Look through all matching certs for suitable issuer */
846 for (i = idx; i < idx + nmatch; i++) {
847 pobj = sk_X509_OBJECT_value(store->objs, i);
848 /* See if we've run past the matches */
849 if (pobj->type != X509_LU_X509)
851 if (ctx->check_issued(ctx, x, pobj->data.x509)) {
853 /* If times check fine, exit with match, else keep looking. */
854 if (ossl_x509_check_cert_time(ctx, pobj->data.x509, -1)) {
855 *issuer = pobj->data.x509;
859 * Leave the so far most recently expired match in *issuer
860 * so we return nearest match if no certificate time is OK.
863 || ASN1_TIME_compare(X509_get0_notAfter(pobj->data.x509),
864 X509_get0_notAfter(*issuer)) > 0)
865 *issuer = pobj->data.x509;
869 if (*issuer != NULL && !X509_up_ref(*issuer)) {
873 X509_STORE_unlock(store);
877 int X509_STORE_set_flags(X509_STORE *xs, unsigned long flags)
879 return X509_VERIFY_PARAM_set_flags(xs->param, flags);
882 int X509_STORE_set_depth(X509_STORE *xs, int depth)
884 X509_VERIFY_PARAM_set_depth(xs->param, depth);
888 int X509_STORE_set_purpose(X509_STORE *xs, int purpose)
890 return X509_VERIFY_PARAM_set_purpose(xs->param, purpose);
893 int X509_STORE_set_trust(X509_STORE *xs, int trust)
895 return X509_VERIFY_PARAM_set_trust(xs->param, trust);
898 int X509_STORE_set1_param(X509_STORE *xs, const X509_VERIFY_PARAM *param)
900 return X509_VERIFY_PARAM_set1(xs->param, param);
903 X509_VERIFY_PARAM *X509_STORE_get0_param(const X509_STORE *xs)
908 void X509_STORE_set_verify(X509_STORE *xs, X509_STORE_CTX_verify_fn verify)
913 X509_STORE_CTX_verify_fn X509_STORE_get_verify(const X509_STORE *xs)
918 void X509_STORE_set_verify_cb(X509_STORE *xs,
919 X509_STORE_CTX_verify_cb verify_cb)
921 xs->verify_cb = verify_cb;
924 X509_STORE_CTX_verify_cb X509_STORE_get_verify_cb(const X509_STORE *xs)
926 return xs->verify_cb;
929 void X509_STORE_set_get_issuer(X509_STORE *xs,
930 X509_STORE_CTX_get_issuer_fn get_issuer)
932 xs->get_issuer = get_issuer;
935 X509_STORE_CTX_get_issuer_fn X509_STORE_get_get_issuer(const X509_STORE *xs)
937 return xs->get_issuer;
940 void X509_STORE_set_check_issued(X509_STORE *xs,
941 X509_STORE_CTX_check_issued_fn check_issued)
943 xs->check_issued = check_issued;
946 X509_STORE_CTX_check_issued_fn X509_STORE_get_check_issued(const X509_STORE *xs)
948 return xs->check_issued;
951 void X509_STORE_set_check_revocation(X509_STORE *xs,
952 X509_STORE_CTX_check_revocation_fn cb)
954 xs->check_revocation = cb;
957 X509_STORE_CTX_check_revocation_fn X509_STORE_get_check_revocation(const X509_STORE *xs)
959 return xs->check_revocation;
962 void X509_STORE_set_get_crl(X509_STORE *xs,
963 X509_STORE_CTX_get_crl_fn get_crl)
965 xs->get_crl = get_crl;
968 X509_STORE_CTX_get_crl_fn X509_STORE_get_get_crl(const X509_STORE *xs)
973 void X509_STORE_set_check_crl(X509_STORE *xs,
974 X509_STORE_CTX_check_crl_fn check_crl)
976 xs->check_crl = check_crl;
979 X509_STORE_CTX_check_crl_fn X509_STORE_get_check_crl(const X509_STORE *xs)
981 return xs->check_crl;
984 void X509_STORE_set_cert_crl(X509_STORE *xs,
985 X509_STORE_CTX_cert_crl_fn cert_crl)
987 xs->cert_crl = cert_crl;
990 X509_STORE_CTX_cert_crl_fn X509_STORE_get_cert_crl(const X509_STORE *xs)
995 void X509_STORE_set_check_policy(X509_STORE *xs,
996 X509_STORE_CTX_check_policy_fn check_policy)
998 xs->check_policy = check_policy;
1001 X509_STORE_CTX_check_policy_fn X509_STORE_get_check_policy(const X509_STORE *xs)
1003 return xs->check_policy;
1006 void X509_STORE_set_lookup_certs(X509_STORE *xs,
1007 X509_STORE_CTX_lookup_certs_fn lookup_certs)
1009 xs->lookup_certs = lookup_certs;
1012 X509_STORE_CTX_lookup_certs_fn X509_STORE_get_lookup_certs(const X509_STORE *xs)
1014 return xs->lookup_certs;
1017 void X509_STORE_set_lookup_crls(X509_STORE *xs,
1018 X509_STORE_CTX_lookup_crls_fn lookup_crls)
1020 xs->lookup_crls = lookup_crls;
1023 X509_STORE_CTX_lookup_crls_fn X509_STORE_get_lookup_crls(const X509_STORE *xs)
1025 return xs->lookup_crls;
1028 void X509_STORE_set_cleanup(X509_STORE *xs,
1029 X509_STORE_CTX_cleanup_fn cleanup)
1031 xs->cleanup = cleanup;
1034 X509_STORE_CTX_cleanup_fn X509_STORE_get_cleanup(const X509_STORE *xs)
1039 int X509_STORE_set_ex_data(X509_STORE *xs, int idx, void *data)
1041 return CRYPTO_set_ex_data(&xs->ex_data, idx, data);
1044 void *X509_STORE_get_ex_data(const X509_STORE *xs, int idx)
1046 return CRYPTO_get_ex_data(&xs->ex_data, idx);
1049 X509_STORE *X509_STORE_CTX_get0_store(const X509_STORE_CTX *ctx)