提交 fbd21640 编写于 作者: D Dr. Stephen Henson

Experimental support for partial chain verification: if an intermediate

certificate is explicitly trusted (using -addtrust option to x509 utility
for example) the verification is sucessful even if the chain is not complete.
上级 04e4b827
...@@ -4,6 +4,16 @@ ...@@ -4,6 +4,16 @@
Changes between 1.0.0 and 1.1.0 [xx XXX xxxx] Changes between 1.0.0 and 1.1.0 [xx XXX xxxx]
*) Initial experimental support for explicitly trusted non-root CAs.
OpenSSL still tries to build a complete chain to a root but if an
intermediate CA has a trust setting included that is used. The first
setting is used: whether to trust or reject.
[Steve Henson]
*) New -verify_name option in command line utilities to set verification
parameters by name.
[Steve Henson]
*) Initial CMAC implementation. WARNING: EXPERIMENTAL, API MAY CHANGE. *) Initial CMAC implementation. WARNING: EXPERIMENTAL, API MAY CHANGE.
Add CMAC pkey methods. Add CMAC pkey methods.
[Steve Henson] [Steve Henson]
......
...@@ -114,6 +114,15 @@ int X509_check_trust(X509 *x, int id, int flags) ...@@ -114,6 +114,15 @@ int X509_check_trust(X509 *x, int id, int flags)
X509_TRUST *pt; X509_TRUST *pt;
int idx; int idx;
if(id == -1) return 1; if(id == -1) return 1;
/* We get this as a default value */
if (id == 0)
{
int rv;
rv = obj_trust(NID_anyExtendedKeyUsage, x, 0);
if (rv != X509_TRUST_UNTRUSTED)
return rv;
return trust_compat(NULL, x, 0);
}
idx = X509_TRUST_get_by_id(id); idx = X509_TRUST_get_by_id(id);
if(idx == -1) return default_trust(id, x, flags); if(idx == -1) return default_trust(id, x, flags);
pt = X509_TRUST_get0(idx); pt = X509_TRUST_get0(idx);
......
...@@ -312,8 +312,13 @@ int X509_verify_cert(X509_STORE_CTX *ctx) ...@@ -312,8 +312,13 @@ int X509_verify_cert(X509_STORE_CTX *ctx)
/* we now have our chain, lets check it... */ /* we now have our chain, lets check it... */
xn=X509_get_issuer_name(x); xn=X509_get_issuer_name(x);
/* Is last certificate looked up self signed? */ i = check_trust(ctx);
if (!ctx->check_issued(ctx,x,x))
/* If explicitly rejected error */
if (i == X509_TRUST_REJECTED)
goto end;
/* If not explicitly trusted then indicate error */
if (i != X509_TRUST_TRUSTED)
{ {
if ((chain_ss == NULL) || !ctx->check_issued(ctx, x, chain_ss)) if ((chain_ss == NULL) || !ctx->check_issued(ctx, x, chain_ss))
{ {
...@@ -351,12 +356,6 @@ int X509_verify_cert(X509_STORE_CTX *ctx) ...@@ -351,12 +356,6 @@ int X509_verify_cert(X509_STORE_CTX *ctx)
if (!ok) goto end; if (!ok) goto end;
/* The chain extensions are OK: check trust */
if (param->trust > 0) ok = check_trust(ctx);
if (!ok) goto end;
/* We may as well copy down any DSA parameters that are required */ /* We may as well copy down any DSA parameters that are required */
X509_get_pubkey_parameters(NULL,ctx->chain); X509_get_pubkey_parameters(NULL,ctx->chain);
...@@ -647,28 +646,35 @@ static int check_name_constraints(X509_STORE_CTX *ctx) ...@@ -647,28 +646,35 @@ static int check_name_constraints(X509_STORE_CTX *ctx)
static int check_trust(X509_STORE_CTX *ctx) static int check_trust(X509_STORE_CTX *ctx)
{ {
#ifdef OPENSSL_NO_CHAIN_VERIFY
return 1;
#else
int i, ok; int i, ok;
X509 *x; X509 *x = NULL;
int (*cb)(int xok,X509_STORE_CTX *xctx); int (*cb)(int xok,X509_STORE_CTX *xctx);
cb=ctx->verify_cb; cb=ctx->verify_cb;
/* For now just check the last certificate in the chain */ /* Check all trusted certificates in chain */
i = sk_X509_num(ctx->chain) - 1; for (i = ctx->last_untrusted; i < sk_X509_num(ctx->chain); i++)
x = sk_X509_value(ctx->chain, i); {
ok = X509_check_trust(x, ctx->param->trust, 0); x = sk_X509_value(ctx->chain, i);
if (ok == X509_TRUST_TRUSTED) ok = X509_check_trust(x, ctx->param->trust, 0);
return 1; /* If explicitly trusted return trusted */
ctx->error_depth = i; if (ok == X509_TRUST_TRUSTED)
ctx->current_cert = x; return X509_TRUST_TRUSTED;
if (ok == X509_TRUST_REJECTED) /* If explicitly rejected notify callback and reject if
ctx->error = X509_V_ERR_CERT_REJECTED; * not overridden.
else */
ctx->error = X509_V_ERR_CERT_UNTRUSTED; if (ok == X509_TRUST_REJECTED)
ok = cb(0, ctx); {
return ok; ctx->error_depth = i;
#endif ctx->current_cert = x;
ctx->error = X509_V_ERR_CERT_REJECTED;
ok = cb(0, ctx);
if (!ok)
return X509_TRUST_REJECTED;
}
}
/* If no trusted certs in chain at all return untrusted and
* allow standard (no issuer cert) etc errors to be indicated.
*/
return X509_TRUST_UNTRUSTED;
} }
static int check_revocation(X509_STORE_CTX *ctx) static int check_revocation(X509_STORE_CTX *ctx)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册