Welcome! Log In Create A New Profile

Advanced

Re: [PATCH] SSL: support automatic selection of ECDH temporary key parameters

Maxim Dounin
April 01, 2014 01:02PM
Hello!

On Thu, Jan 30, 2014 at 03:23:01PM -0800, Piotr Sikora wrote:

> Hello,
> slightly better patch attached.
>
> Hopefully, now that ALPN (OpenSSL-1.0.2+ feature) is in, this can be
> also committed :)
>
> Best regards,
> Piotr Sikora
>
>
> # HG changeset patch
> # User Piotr Sikora <piotr@cloudflare.com>
> # Date 1391123946 28800
> # Thu Jan 30 15:19:06 2014 -0800
> # Node ID 63c549cc2e817772979238f055b72a4f96198a2a
> # Parent 2e40188f83ef5bf1ae5afe0dd445689049f46a5c
> SSL: support automatic selection of ECDH temporary key parameters.
>
> When compiled against OpenSSL-1.0.2+, the colon separated list of
> supported curves can be provided using either curve NIDs:
>
> ssl_ecdh_curve secp521r1:secp384r1:prime256v1;
>
> or names:
>
> ssl_ecdh_curve P-521:P-384:P-256;
>
> Signed-off-by: Piotr Sikora <piotr@cloudflare.com>
>
> diff -r 2e40188f83ef -r 63c549cc2e81 src/event/ngx_event_openssl.c
> --- a/src/event/ngx_event_openssl.c Thu Jan 30 19:13:12 2014 +0400
> +++ b/src/event/ngx_event_openssl.c Thu Jan 30 15:19:06 2014 -0800
> @@ -681,6 +681,23 @@ ngx_ssl_ecdh_curve(ngx_conf_t *cf, ngx_s
> {
> #if OPENSSL_VERSION_NUMBER >= 0x0090800fL
> #ifndef OPENSSL_NO_ECDH
> +#ifdef SSL_CTRL_SET_ECDH_AUTO
> +
> + if (SSL_CTX_set1_curves_list(ssl->ctx, name->data) == 0) {
> + ngx_ssl_error(NGX_LOG_EMERG, ssl->log, 0,
> + "Unknown curve in \"%s\"", name->data);
> + return NGX_ERROR;
> + }
> +
> + if (SSL_CTX_set_ecdh_auto(ssl->ctx, 1) == 0) {
> + ngx_ssl_error(NGX_LOG_EMERG, ssl->log, 0,
> + "Unable to set automatic curve selection for \"%s\"",
> + name->data);
> + return NGX_ERROR;
> + }
> +
> +#else
> +
> int nid;
> EC_KEY *ecdh;
>
> @@ -710,6 +727,8 @@ ngx_ssl_ecdh_curve(ngx_conf_t *cf, ngx_s
> SSL_CTX_set_tmp_ecdh(ssl->ctx, ecdh);
>
> EC_KEY_free(ecdh);
> +
> +#endif
> #endif
> #endif

Sorry for late reponse, but I finally managed to get some time to
look into the SSL_CTX_set_ecdh_auto() / SSL_CTX_set1_curves_list()
support in yet-to-be-released OpenSSL 1.0.2.

Comments about the patch below, in no particular order:

- Suggested code doesn't seem to allow to use the default list of
curves, as normally available with just a call to
SSL_CTX_set_ecdh_auto(); this seems to be what OpenSSL
recommends to use by default, and we may want to follow.

- Error messages in the ngx_ssl_ecdh_curve() are way off from
what's normally used in ngx_event_openssl.c, and probably
it's not a good idea to use similar messages in the new code.

- If nginx was compiled with OpenSSL 1.0.2, but used with an
older version, things will not work at all; this is not something
completely unacceptable, but it's something we may want to
avoid.

- SSL_CTX_set_options(SSL_OP_SINGLE_ECDH_USE) is not used
with OpenSSL 1.0.2, and this looks just wrong.

--
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: support automatic selection of ECDH temporary key parameters

Piotr Sikora 1719 August 05, 2013 04:54PM

Re: [PATCH] SSL: support automatic selection of ECDH temporary key parameters

Piotr Sikora 1097 November 04, 2013 05:30AM

Re: [PATCH] SSL: support automatic selection of ECDH temporary key parameters

Piotr Sikora 870 November 04, 2013 04:16PM

Re: [PATCH] SSL: support automatic selection of ECDH temporary key parameters

Piotr Sikora 770 December 13, 2013 05:22PM

Re: [PATCH] SSL: support automatic selection of ECDH temporary key parameters

Piotr Sikora 800 January 30, 2014 06:24PM

Re: [PATCH] SSL: support automatic selection of ECDH temporary key parameters

Maxim Dounin 1036 April 01, 2014 01:02PM

Re: [PATCH] SSL: support automatic selection of ECDH temporary key parameters

Piotr Sikora 1168 April 06, 2014 10:10PM

Re: [PATCH] SSL: support automatic selection of ECDH temporary key parameters

Maxim Dounin 1939 April 07, 2014 07:28AM

Re: [PATCH] SSL: support automatic selection of ECDH temporary key parameters

Piotr Sikora 623 April 15, 2014 03:46PM

Re: [PATCH] SSL: support automatic selection of ECDH temporary key parameters

Maxim Dounin 682 April 16, 2014 06:02AM

Re: [PATCH] SSL: support automatic selection of ECDH temporary key parameters

Piotr Sikora 1053 April 22, 2014 08:00AM



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

Online Users

Guests: 159
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