Skip to content

Commit d5f3517

Browse files
committed
Merge branch 'master' of github.com:cherokee/webserver
2 parents 4c1b898 + 760fe7c commit d5f3517

1 file changed

Lines changed: 28 additions & 0 deletions

File tree

cherokee/cryptor_libssl.c

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,9 @@ _vserver_new (cherokee_cryptor_t *cryp,
348348
const char *error;
349349
long options;
350350
int verify_mode = SSL_VERIFY_NONE;
351+
#if !defined(OPENSSL_NO_EC) && OPENSSL_VERSION_NUMBER >= 0x10000000L && OPENSSL_VERSION_NUMBER < 0x10002000L
352+
EC_KEY *ecdh;
353+
#endif
351354

352355
CHEROKEE_NEW_STRUCT (n, cryptor_vserver_libssl);
353356

@@ -375,10 +378,35 @@ _vserver_new (cherokee_cryptor_t *cryp,
375378
*/
376379
SSL_CTX_set_tmp_dh_callback (n->context, tmp_dh_cb);
377380

381+
/* Set ecliptic curve key parameters
382+
*/
383+
#if !defined(OPENSSL_NO_EC) && OPENSSL_VERSION_NUMBER >= 0x10002000L
384+
/* OpenSSL >= 1.0.2 automatically handles ECDH temporary key parameter
385+
* selection. */
386+
SSL_CTX_set_ecdh_auto(n->context, 1);
387+
#elif !defined(OPENSSL_NO_EC) && OPENSSL_VERSION_NUMBER >= 0x10000000L
388+
/* For OpenSSL < 1.0.2, ECDH temporary key parameter selection must be
389+
* performed manually. Default to the NIST P-384 (secp384r1) curve
390+
* to be compliant with RFC 6460 when AES-256 TLS cipher suites are in
391+
* use. This does make Cherokee non-compliant with RFC 6460 when
392+
* AES-128 TLS cipher suites are in use as they "MUST" support
393+
* NIST P-256 (prime256v1) but only "SHOULD" support NIST P-384
394+
* (secp384v1). However 99.9% of clients support both or neither.
395+
*/
396+
ecdh = EC_KEY_new_by_curve_name(NID_secp384r1);
397+
if (ecdh != NULL) {
398+
SSL_CTX_set_tmp_ecdh(n->context, ecdh);
399+
EC_KEY_free(ecdh);
400+
}
401+
#endif
402+
378403
/* Set the SSL context options:
379404
*/
380405
options = SSL_OP_ALL;
381406
options |= SSL_OP_SINGLE_DH_USE;
407+
#ifdef SSL_OP_SINGLE_ECDH_USE
408+
options |= SSL_OP_SINGLE_ECDH_USE;
409+
#endif
382410

383411
#ifdef SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS
384412
options |= SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS;

0 commit comments

Comments
 (0)