2

Currently I'm working on server based application which is using libssl for ssl implementation. When I use RSA certificate, everything works fine but when I use Elliptic Curve key with my certificate, I'm unable to connect to server. When I try to curl, it gives following error

NSS error -12286 (SSL_ERROR_NO_CYPHER_OVERLAP)

Cannot communicate securely with peer: no common encryption algorithm(s).

Closing connection 0

By using "openssl s_client" command, I came to know that server is only offering "ECDH-ECDSA-AES256-GCM-SHA384" but curl or chrome are unable to recognise this cipher suite.

Steps to produce certificate are:

openssl ecparam -name prime256v1 -genkey -noout -out ecCert.key

openssl req -new -key ecCert.key -out ecCert.csr -subj /CN=servername.com

openssl x509 -req -in ecCert.csr -CA ./rootCA.pem -CAkey ./rootCA.key -CAcreateserial -sha256 -out ecCert.crt -days 500

cat ecCert.crt ecCert.key > ecCert.pem

Is there a way to configure ciphering method of server?

P.S. I'm using openssl version "OpenSSL 1.0.2g 1 Mar 2016"

I have also tried to set cipher list by using SSL_CTX_set_cipher_list(ctx, ciphers)

Community
  • 1
  • 1

1 Answers1

4

I have also tried to set cipher list by using SSL_CTX_set_cipher_list(ctx, ciphers)

That's actually the correct way. The relevant cipher in OpenSSL syntax is ECDHE-ECDSA-AES128-GCM-SHA256. But note that in order to use any kind of ECC ciphers at the server side you also need to setup the curve to use with SSL_CTX_set_tmp_ecdh.

For way more extensive information see the excellent answer by jww at Server with ECDHE key and cert not working.

Community
  • 1
  • 1
Steffen Ullrich
  • 114,247
  • 10
  • 131
  • 172
  • Thanks for co-operation. I'm already using 'SSL_CTX_set_tmp_ecdh'. I also tried 'SSL_CTX_set_tmp_ecdh_callback' method explained in provided link. I also tried to use 'SSL_CTX_set_ecdh_auto' but problem is still there. Am I still missing something? – Usama Anwar Apr 08 '16 at 07:56
  • I have no idea how you code looks like (see [How to create a Minimal, Complete, and Verifiable example](http://stackoverflow.com/help/mcve)) but obviously you are not offering the ..SHA256 cipher you write about in the title of your question but ..SHA384 you write about in the question itself. And this cipher is not supported by Chrome and Firefox. – Steffen Ullrich Apr 08 '16 at 08:14
  • **Problem is solved.*** In addition to setup the curve to use with SSL_CTX_set_tmp_ecdh, I also needed to call SSL_set_tmp_ecdh after setting context for SSL instance. – Usama Anwar Apr 08 '16 at 15:46
  • @UsamaAnwar: that's strange because I don't need to do this, i.e. SSL_CTX_set_tmp_ecdh is sufficient. And that would also not explain why it did the ...SHA384 w/o this but the SHA256 not. I still believe the problem is somewhere else. – Steffen Ullrich Apr 08 '16 at 16:01
  • I know it was not needed that's why I didn't use it earlier. But it seems it solved the problem temporarily. If I found something else, I'll definitely update here. Thanks – Usama Anwar Apr 10 '16 at 14:35