Welcome! Log In Create A New Profile

Advanced

Re: [PATCH] SSL: fix order of checks during SSL certificate verification

Maxim Dounin
August 17, 2016 08:38PM
Hello!

On Tue, Aug 09, 2016 at 12:51:38PM -0700, Piotr Sikora wrote:

> Hey Maxim,
>
> > This behaviour is explicitly documented for years. The BUGS
> > section outlines that the API is not intuitive and requires use of
> > SSL_get_peer_certificate() in addition ot SSL_get_verify_result().
>
> Exactly.
>
> > And this is what nginx does. I don't see compelling reasons to
> > change the order of the calls here.
>
> No, it doesn't, which is the reason for this patch in the first
> place... NGINX uses the result of SSL_get_verify_result() without
> calling SSL_get_peer_certificate(), which is what the BUGS section
> requires.

Calling SSL_get_peer_certificate() is only needed if
SSL_get_verify_result() returns X509_V_OK, to distinguish two of
its different meanings:

X509_V_OK
The verification succeeded or no peer certificate was presented.

And that's what nginx does.

> Also, this breaks implementations (i.e. BoringSSL) that are a bit more
> strict and don't use X509_V_OK as the initial value.

Ok, this looks like the real reason for the patch. This looks
like an API change in BoringSSL, and should be threated
accordingly.

Given the number of various API changes BoringSSL introduces here
and there - we probably don't want to follow, at least till some
version is actually released.

> > This looks like a separate patch, or two patches.
>
> Fair enough.
>
> > Though I'm
> > somewhat sceptical about the use of "upstream" and "client" in
> > error messages introduced, this looks like a wrong approach for a
> > generic SSL code.
>
> What you would prefer, then?
>
> 1. Returning error string back the the caller?
> 2. Returning "rc" back to the caller and adding another function to
> abstract X509_verify_cert_error_string()?
> 3. Adding the caller string ("client" or "upstream") as the parameter
> and writing error from within the function?

I can't say I like either of the variants. (1) will require
memory allocations, (2) looks hardly portable (what if another
library will have different rc values? or will have more than one
error string to print?), and (3) looks strange.

May be something like "peer" in error messages instead would be a
better solution, assuming context is already known from the
c->log->action == "SSL handshaking to upstream". Alternatively,
we can consider abstracting printing of verification results
errors with something similar to ngx_ssl_error().

> > As well as magic values in the "verify" argument,
>
> Good call.
>
> > and the change of the ngx_ssl_check_host() semantics.
>
> You mean the introduction of error logs? If so, then it seems that
> returning "rc" and adding another function to retrieve the error
> string would be the best way to keep the behavior as close to the
> existing one as possible.

There are two changes in the ngx_ssl_check_host() function in the
patch:

- an API change which moves error printing to the function;

- a semantics change which adds certificate verification check to
the function.

Both has problems. API changes tend to break 3rd party modules,
and so it's better to avoid them unless really needed. The
semantics change in question may not be adequate for various
non-trivial cases when one want to check verification results but
not host or vice versa.

--
Maxim Dounin
http://nginx.org/

_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

[PATCH] SSL: fix order of checks during SSL certificate verification

Piotr Sikora 972 August 02, 2016 06:26PM

Re: [PATCH] SSL: fix order of checks during SSL certificate verification

Maxim Dounin 344 August 03, 2016 11:56PM

Re: [PATCH] SSL: fix order of checks during SSL certificate verification

Piotr Sikora 241 August 09, 2016 03:52PM

Re: [PATCH] SSL: fix order of checks during SSL certificate verification

Maxim Dounin 305 August 17, 2016 08:38PM

Re: [PATCH] SSL: fix order of checks during SSL certificate verification

Piotr Sikora 238 August 18, 2016 10:48PM

Re: [PATCH] SSL: fix order of checks during SSL certificate verification

Maxim Dounin 250 August 21, 2016 10:04AM

Re: [PATCH] SSL: fix order of checks during SSL certificate verification

Piotr Sikora 201 August 31, 2016 06:26PM

Re: [PATCH] SSL: fix order of checks during SSL certificate verification

Maxim Dounin 216 September 01, 2016 11:28AM

Re: [PATCH] SSL: fix order of checks during SSL certificate verification

Piotr Sikora 217 September 01, 2016 05:18PM

Re: [PATCH] SSL: fix order of checks during SSL certificate verification

Maxim Dounin 231 September 02, 2016 08:50AM

Re: [PATCH] SSL: fix order of checks during SSL certificate verification

Piotr Sikora 339 September 02, 2016 07:20PM

Re: [PATCH] SSL: fix order of checks during SSL certificate verification

Maxim Dounin 176 September 03, 2016 11:30AM

Re: [PATCH] SSL: fix order of checks during SSL certificate verification

Piotr Sikora 233 September 03, 2016 06:28PM

Re: [PATCH] SSL: fix order of checks during SSL certificate verification

Maxim Dounin 359 September 05, 2016 10:18AM



Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 103
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready