77 #define CRL_SCORE_NOCRITICAL 0x100
81 #define CRL_SCORE_SCOPE 0x080
85 #define CRL_SCORE_TIME 0x040
89 #define CRL_SCORE_ISSUER_NAME 0x020
93 #define CRL_SCORE_VALID (CRL_SCORE_NOCRITICAL|CRL_SCORE_TIME|CRL_SCORE_SCOPE)
97 #define CRL_SCORE_ISSUER_CERT 0x018
101 #define CRL_SCORE_SAME_PATH 0x008
105 #define CRL_SCORE_AKID 0x004
109 #define CRL_SCORE_TIME_DELTA 0x002
122 unsigned int *preasons,
129 X509 **pissuer,
int *pcrl_score);
130 static int crl_crldp_check(
X509 *x,
X509_CRL *crl,
int crl_score,
131 unsigned int *preasons);
147 static int x509_subject_cmp(
X509 **
a,
X509 **
b)
155 X509 *x,*xtmp,*chain_ss=NULL;
162 if (ctx->
cert == NULL)
172 if (ctx->chain == NULL)
185 if (ctx->untrusted != NULL
200 if (depth < num)
break;
210 if (ctx->untrusted != NULL)
212 xtmp=find_issuer(ctx, sktmp,x);
258 if (ok == 1) X509_free(xtmp);
288 if (depth < num)
break;
295 if (ok < 0)
return ok;
313 if ((chain_ss == NULL) || !ctx->
check_issued(ctx, x, chain_ss))
339 ok = check_chain_extensions(ctx);
345 ok = check_name_constraints(ctx);
351 if (param->
trust > 0) ok = check_trust(ctx);
369 ok=internal_verify(ctx);
372 #ifndef OPENSSL_NO_RFC3779
390 if (chain_ss != NULL) X509_free(chain_ss);
434 *issuer = find_issuer(ctx, ctx->
other_ctx, x);
451 #ifdef OPENSSL_NO_CHAIN_VERIFY
454 int i, ok=0, must_be_ca, plen = 0;
457 int proxy_path_length = 0;
459 int allow_proxy_certs;
475 allow_proxy_certs = 0;
484 if (getenv(
"OPENSSL_ALLOW_PROXY_CERTS"))
485 allow_proxy_certs = 1;
516 && (ret != 1) && (ret != 0))
569 && (plen > (x->
ex_pathlen + proxy_path_length + 1)))
645 #ifdef OPENSSL_NO_CHAIN_VERIFY
683 for(i = 0; i <= last; i++)
686 ok = check_cert(ctx);
707 ok = ctx->
get_crl(ctx, &crl, x);
709 ok = get_crl_delta(ctx, &crl, &dcrl, x);
820 X509 **pissuer,
int *pscore,
unsigned int *preasons,
823 int i, crl_score, best_score = *pscore;
824 unsigned int reasons, best_reasons = 0;
827 X509 *crl_issuer = NULL, *best_crl_issuer = NULL;
833 crl_score = get_crl_score(ctx, &crl_issuer, &reasons, crl, x);
835 if (crl_score > best_score)
838 best_crl_issuer = crl_issuer;
839 best_score = crl_score;
840 best_reasons = reasons;
847 X509_CRL_free(*pcrl);
849 *pissuer = best_crl_issuer;
850 *pscore = best_score;
851 *preasons = best_reasons;
855 X509_CRL_free(*pdcrl);
858 get_delta_sk(ctx, pdcrl, pscore, best_crl, crls);
955 if (check_delta_base(delta, base))
957 if (check_crl_time(ctx, delta, 0))
975 unsigned int *preasons,
980 unsigned int tmp_reasons = *preasons, crl_reasons;
1015 if (check_crl_time(ctx, crl, 0))
1019 crl_akid_check(ctx, crl, pissuer, &crl_score);
1028 if (crl_crldp_check(x, crl, crl_score, &crl_reasons))
1031 if (!(crl_reasons & ~tmp_reasons))
1033 tmp_reasons |= crl_reasons;
1037 *preasons = tmp_reasons;
1044 X509 **pissuer,
int *pcrl_score)
1046 X509 *crl_issuer = NULL;
1061 *pissuer = crl_issuer;
1066 for (cidx++; cidx <
sk_X509_num(ctx->chain); cidx++)
1074 *pissuer = crl_issuer;
1094 *pissuer = crl_issuer;
1118 crl_ctx.crls = ctx->crls;
1133 ret = check_crl_chain(ctx, ctx->chain, crl_ctx.chain);
1151 X509 *cert_ta, *crl_ta;
1170 GENERAL_NAMES *gens = NULL;
1193 else if (b->
type == 1)
1253 static int crl_crldp_check(
X509 *x,
X509_CRL *crl,
int crl_score,
1254 unsigned int *preasons)
1273 if (crldp_check_crlissuer(dp, crl, crl_score))
1296 X509 *issuer = NULL;
1298 unsigned int reasons;
1299 X509_CRL *crl = NULL, *dcrl = NULL;
1303 ok = get_crl_sk(ctx, &crl, &dcrl,
1304 &issuer, &crl_score, &reasons, ctx->crls);
1311 skcrl = ctx->lookup_crls(ctx, nm);
1317 get_crl_sk(ctx, &crl, &dcrl, &issuer, &crl_score, &reasons, skcrl);
1340 X509 *issuer = NULL;
1342 int ok = 0, chnum, cnum;
1352 else if (cnum < chnum)
1411 ok = check_crl_time(ctx, crl, 1);
1644 ok = check_cert_time(ctx, xs);
1676 char buff1[24],buff2[24],*
p;
1681 str=(
char *)ctm->
data;
1684 if ((i < 11) || (i > 17))
return 0;
1691 if (i < 13)
return 0;
1697 if ((*str ==
'Z') || (*str ==
'-') || (*str ==
'+'))
1698 { *(p++)=
'0'; *(p++)=
'0'; }
1707 while ((*str >=
'0') && (*str <=
'9')) str++;
1718 if ((*str !=
'+') && (*str !=
'-'))
1720 offset=((str[1]-
'0')*10+(str[2]-
'0'))*60;
1721 offset+=(str[3]-
'0')*10+(str[4]-
'0');
1727 atm.
length=
sizeof(buff2);
1728 atm.
data=(
unsigned char *)buff2;
1735 i=(buff1[0]-
'0')*10+(buff1[1]-
'0');
1737 j=(buff2[0]-
'0')*10+(buff2[1]-
'0');
1740 if (i < j)
return -1;
1741 if (i > j)
return 1;
1743 i=strcmp(buff1,buff2);
1761 int offset_day,
long offset_sec, time_t *in_tm)
1765 if (in_tm) t = *in_tm;
1809 for (j=i-1; j >= 0; j--)
1827 new_func, dup_func, free_func);
1870 if (!ctx->chain || !(chain =
sk_X509_dup(ctx->chain)))
return NULL;
1930 int purpose,
int trust)
1934 if (!purpose) purpose = def_purpose;
1959 if (!trust) trust = ptmp->
trust;
2003 ctx->untrusted=chain;
2071 if (store && store->
verify)
2074 ctx->
verify = internal_verify;
2096 if (store && store->lookup_certs)
2097 ctx->lookup_certs = store->lookup_certs;
2099 ctx->lookup_certs = X509_STORE_get1_certs;
2101 if (store && store->lookup_crls)
2102 ctx->lookup_crls = store->lookup_crls;
2104 ctx->lookup_crls = X509_STORE_get1_crls;
2136 if (ctx->
param != NULL)
2142 if (ctx->
tree != NULL)
2147 if (ctx->chain != NULL)