I have to secure my data sharing program (i use QTcpServer i QTcpSocket). I decided to use QSslSocket and began from the simple examples from the internet. At the beginning I encountered the problem that I can not solve. I downloaded Win32OpenSSL_Light-1_0_0d and generated a key and certificate in accordance with Guide to SSL certificates and certificate authorities
Next I created a server and client. When trying to connect my server throws an error. Similarly, when trying to connect to server via the client securesocketclient example from the documentation.
Error during SSL handshake: error:1408A0C1:SSL routines:SSL3_GET_CLIENT_HELLO:no shared cipher
Error during SSL handshake: error:1408A0C1:SSL routines:SSL3_GET_CLIENT_HELLO:no shared cipher
To copy to clipboard, switch view to plain text mode
Certificates are in server directory, paths is correct.
Please help in resolve the problem.
{
Q_OBJECT
QSslSocket *serverSocket;
public:
void start(quint16 port);
void incomingConnection(int socketDescr);
public slots:
void readyToRead();
};
SslServer
::SslServer(QObject *parent
) :{
}
void SslServer::start(quint16 port)
{
}
void SslServer::readyToRead()
{
//qDebug() << this->serverSocket->readAll();
}
{
qDebug() << serverSocket->errorString();
}
void SslServer::incomingConnection(int socketDescr)
{
serverSocket = new QSslSocket;
if(serverSocket->setSocketDescriptor(socketDescr))
{
connect(serverSocket, SIGNAL(readyRead()), this, SLOT(readyToRead()));
serverSocket->setProtocol(QSsl::SslV3);
serverSocket->setPrivateKey("ca.key");
serverSocket->setLocalCertificate("ca.cer");
serverSocket->startServerEncryption();
}
else
{
delete serverSocket;
}
}
class SslServer : public QTcpServer
{
Q_OBJECT
QSslSocket *serverSocket;
public:
SslServer(QObject *parent = 0);
void start(quint16 port);
void incomingConnection(int socketDescr);
public slots:
void readyToRead();
void sslErrors(QAbstractSocket::SocketError error);
};
SslServer::SslServer(QObject *parent) :
QTcpServer(parent)
{
}
void SslServer::start(quint16 port)
{
listen(QHostAddress::Any, port);
}
void SslServer::readyToRead()
{
//qDebug() << this->serverSocket->readAll();
}
void SslServer::sslErrors(QAbstractSocket::SocketError error)
{
qDebug() << serverSocket->errorString();
}
void SslServer::incomingConnection(int socketDescr)
{
serverSocket = new QSslSocket;
if(serverSocket->setSocketDescriptor(socketDescr))
{
connect(serverSocket, SIGNAL(readyRead()), this, SLOT(readyToRead()));
connect(serverSocket, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(sslErrors(QAbstractSocket::SocketError)));
serverSocket->setProtocol(QSsl::SslV3);
serverSocket->setPrivateKey("ca.key");
serverSocket->setLocalCertificate("ca.cer");
serverSocket->startServerEncryption();
}
else
{
delete serverSocket;
}
}
To copy to clipboard, switch view to plain text mode
Bookmarks