diff options
author | jsing <> | 2017-01-03 17:13:41 +0000 |
---|---|---|
committer | jsing <> | 2017-01-03 17:13:41 +0000 |
commit | 6070037b9b7f8d391060efcb8e1123ff682da427 (patch) | |
tree | 5a3e601f0663f578d8b7766ab16ca3035c1e5b14 | |
parent | 5da7b92521d672c4c9ed6738c3b4f70f6da48894 (diff) | |
download | openbsd-6070037b9b7f8d391060efcb8e1123ff682da427.tar.gz openbsd-6070037b9b7f8d391060efcb8e1123ff682da427.tar.bz2 openbsd-6070037b9b7f8d391060efcb8e1123ff682da427.zip |
Revert previous - the original code was correct since X509_verify_cert()
should not have changed the X509_STORE_CTX error value on success and it
was initialised to X509_V_OK by X509_STORE_CTX_init(). Other software also
depends on this behaviour.
Previously X509_verify_cert() was mishandling the X509_STORE_CTX error
value when validating alternate chains. This has been fixed and further
changes now explicitly ensure that the error value will be set to X509_V_OK
if X509_verify_cert() returns success.
-rw-r--r-- | src/lib/libtls/tls.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/src/lib/libtls/tls.c b/src/lib/libtls/tls.c index 53a8506622..e192942b6b 100644 --- a/src/lib/libtls/tls.c +++ b/src/lib/libtls/tls.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: tls.c,v 1.54 2017/01/02 22:03:56 tedu Exp $ */ | 1 | /* $OpenBSD: tls.c,v 1.55 2017/01/03 17:13:41 jsing Exp $ */ |
2 | /* | 2 | /* |
3 | * Copyright (c) 2014 Joel Sing <jsing@openbsd.org> | 3 | * Copyright (c) 2014 Joel Sing <jsing@openbsd.org> |
4 | * | 4 | * |
@@ -369,19 +369,19 @@ static int | |||
369 | tls_ssl_cert_verify_cb(X509_STORE_CTX *x509_ctx, void *arg) | 369 | tls_ssl_cert_verify_cb(X509_STORE_CTX *x509_ctx, void *arg) |
370 | { | 370 | { |
371 | struct tls *ctx = arg; | 371 | struct tls *ctx = arg; |
372 | int x509_err, rv; | 372 | int x509_err; |
373 | 373 | ||
374 | if (ctx->config->verify_cert == 0) | 374 | if (ctx->config->verify_cert == 0) |
375 | return (1); | 375 | return (1); |
376 | 376 | ||
377 | if ((rv = X509_verify_cert(x509_ctx)) < 0) { | 377 | if ((X509_verify_cert(x509_ctx)) < 0) { |
378 | tls_set_errorx(ctx, "X509 verify cert failed"); | 378 | tls_set_errorx(ctx, "X509 verify cert failed"); |
379 | return (0); | 379 | return (0); |
380 | } | 380 | } |
381 | if (rv == 1) | ||
382 | return 1; | ||
383 | 381 | ||
384 | x509_err = X509_STORE_CTX_get_error(x509_ctx); | 382 | x509_err = X509_STORE_CTX_get_error(x509_ctx); |
383 | if (x509_err == X509_V_OK) | ||
384 | return (1); | ||
385 | 385 | ||
386 | tls_set_errorx(ctx, "certificate verification failed: %s", | 386 | tls_set_errorx(ctx, "certificate verification failed: %s", |
387 | X509_verify_cert_error_string(x509_err)); | 387 | X509_verify_cert_error_string(x509_err)); |