Move peer chain security checks into x509_vfy.c
A new X509_VERIFY_PARAM_set_auth_level() function sets the
authentication security level. For verification of SSL peers, this
is automatically set from the SSL security level. Otherwise, for
now, the authentication security level remains at (effectively) 0
by default.
The new "-auth_level" verify(1) option is available in all the
command-line tools that support the standard verify(1) options.
New verify(1) tests added to check enforcement of chain signature
and public key security levels. Also added new tests of enforcement
of the verify_depth limit.
Updated documentation.
Reviewed-by: Dr. Stephen Henson <steve@openssl.org>
diff --git a/ssl/ssl_cert.c b/ssl/ssl_cert.c
index 4081ebe..24ac352 100644
--- a/ssl/ssl_cert.c
+++ b/ssl/ssl_cert.c
@@ -494,6 +494,12 @@
return (0);
}
param = X509_STORE_CTX_get0_param(&ctx);
+ /*
+ * XXX: Separate @AUTHSECLEVEL and @TLSSECLEVEL would be useful at some
+ * point, for now a single @SECLEVEL sets the same policy for TLS crypto
+ * and PKI authentication.
+ */
+ X509_VERIFY_PARAM_set_auth_level(param, SSL_get_security_level(s));
/* Set suite B flags if needed */
X509_STORE_CTX_set_flags(&ctx, tls1_suiteb(s));
@@ -520,17 +526,8 @@
if (s->ctx->app_verify_callback != NULL)
i = s->ctx->app_verify_callback(&ctx, s->ctx->app_verify_arg);
- else {
+ else
i = X509_verify_cert(&ctx);
-# if 0
- /* Dummy error calls so mkerr generates them */
- SSLerr(SSL_F_SSL_VERIFY_CERT_CHAIN, SSL_R_EE_KEY_TOO_SMALL);
- SSLerr(SSL_F_SSL_VERIFY_CERT_CHAIN, SSL_R_CA_KEY_TOO_SMALL);
- SSLerr(SSL_F_SSL_VERIFY_CERT_CHAIN, SSL_R_CA_MD_TOO_WEAK);
-# endif
- if (i > 0)
- i = ssl_security_cert_chain(s, ctx.chain, NULL, 1);
- }
s->verify_result = ctx.error;
sk_X509_pop_free(s->verified_chain, X509_free);
@@ -894,12 +891,18 @@
* ignore the error return from this call. We're not actually verifying
* the cert - we're just building as much of the chain as we can
*/
- X509_verify_cert(&xs_ctx);
+ (void) X509_verify_cert(&xs_ctx);
/* Don't leave errors in the queue */
ERR_clear_error();
i = ssl_security_cert_chain(s, xs_ctx.chain, NULL, 0);
if (i != 1) {
X509_STORE_CTX_cleanup(&xs_ctx);
+#if 0
+ /* Dummy error calls so mkerr generates them */
+ SSLerr(SSL_F_SSL_ADD_CERT_CHAIN, SSL_R_EE_KEY_TOO_SMALL);
+ SSLerr(SSL_F_SSL_ADD_CERT_CHAIN, SSL_R_CA_KEY_TOO_SMALL);
+ SSLerr(SSL_F_SSL_ADD_CERT_CHAIN, SSL_R_CA_MD_TOO_WEAK);
+#endif
SSLerr(SSL_F_SSL_ADD_CERT_CHAIN, i);
return 0;
}