I am writing a server which accepts SSL connections. I have generated a self signed certificate:
openssl req -new -x509 -days 365 -nodes -out self.pem -keyout self.pem -subj "/CN=myhostname"
SSL_accept
fails with this message:
140121764049248:error:1408A0C1:SSL routines:ssl3_get_client_hello:no shared cipher:s3_srvr.c:1417:
Here is a part of the server code:
sslCtx = (SSL_CTX_new(SSLv23_server_method());
if (!sslCtx){
ERR_print_errors_fp(stderr);
throw runtime_error("SSL_CTX_new failed");
}
ssl = SSL_new(sslCtx);
if (!ssl)
throw runtime_error("SSL_new failed");
if (SSL_CTX_use_PrivateKey_file(sslCtx, keyFile.c_str(),
SSL_FILETYPE_PEM) != 1)
throw runtime_error("Unable to load private key file" + keyFile);
if (SSL_CTX_use_certificate_file(sslCtx, certFile.c_str(),
SSL_FILETYPE_PEM) != 1)
throw runtime_error("Unable to load certificate file" + certFile);
if (SSL_set_fd(ssl, socket) != 1)
throw runtime_error("SSL_set_fd failed");
if (SSL_accept(ssl) != 1){
ERR_print_errors_fp(stderr);
throw runtime_error("SSL_accept failed");
}
I tried to test the server:
openssl s_client -cipher RSA -connect myhostname:33221 -tls1 -CApath . -servername myhostname
and got
CONNECTED(00000003)
139898773520408:error:14094410:SSL routines:ssl3_read_bytes:sslv3 alert handshake failure:s3_pkt.c:1487:SSL alert number 40
139898773520408:error:1409E0E5:SSL routines:ssl3_write_bytes:ssl handshake failure:s3_pkt.c:656:
---
no peer certificate available
---
No client certificate CA names sent
---
SSL handshake has read 7 bytes and written 0 bytes
---
New, (NONE), Cipher is (NONE)
Secure Renegotiation IS NOT supported
Compression: NONE
Expansion: NONE
No ALPN negotiated
SSL-Session:
Protocol : TLSv1
Cipher : 0000
Session-ID:
Session-ID-ctx:
Master-Key:
Key-Arg : None
PSK identity: None
PSK identity hint: None
SRP username: None
Start Time: 1496232544
Timeout : 7200 (sec)
Verify return code: 0 (ok)
---
I am using OpenSSL 1.0.2g.