I have a php ssl client, and a C++ Qt ssl server, and I need the client to be authenticated rather than the server.
The reason is that the C++ Qt ssl server actually runs on a desktop application, and i don't want to provide the desktop application with a private key for security reasons and also because the server does not need to authenticated it self.
So I had the client provided with certificate and private key, while the server has only the certificate that authenticates the client.
however in the above scenario I get and ssl error from the server side, the handshake fails for lack of shared ciphers.
If i provide the server with its own local private key and certificate the handshake is done successfully.
below some php code to set up ssl:
/* $local_cert_path is a file containing a complete certificate
* verification chain and the private key
*/
if (! is_file($local_cert_path))
{
throw new Exception(sprintf('cannot find certificate path: %s', $local_cert_path));
}
$this->ctx = stream_context_create();
stream_context_set_option($this->ctx, 'ssl', 'verify_peer', FALSE);
stream_context_set_option($this->ctx, 'ssl', 'allow_self_signed', TRUE);
stream_context_set_option($this->ctx, 'ssl', 'local_cert', $local_cert_path);
and C++ (Qt):
QList<QSslCertificate> certs = cacerts();
socket->setCaCertificates(certs); // loading the CA
// socket->setLocalCertificate(":/res/cert.pem", QSsl::Pem);
// socket->setPrivateKey(":/res/key.pem");
socket->setPeerVerifyMode(QSslSocket::VerifyPeer);
socket->setProtocol(QSsl::TlsV1);
If I provide the server with its own local private key and certificate (uncommenting the two lines above) then the handshake works.