Unsolved Create a SSl Connection only with Slots and Signals ...
-
You should use the new connect syntax, this will give you compile time error rather than runtime error.
-
@SGaist
Hi,
I try to find the new way of using the "Connection" command and failed.
I always used this documentation as a reference.
http://doc.qt.io/qt-5/signalsandslots.htmlIs there a other, better documentation for QT ?
Do you have an example, sorry asking for.Best regards
R. -
@Ritchie There is nothing wrong with this documentation.
In the link you posted the new way to connect signals and slots is described with examples:QObject::connect(&a, &Counter::valueChanged, &b, &Counter::setValue);
-
@jsulm
But what is about thisYou should use the new connect syntax, this will give you compile time error rather than runtime error
Where is the "new connect syntax" descripted ?
Best regards
R. -
@Ritchie This is the new syntax:
QObject::connect(&a, &Counter::valueChanged, &b, &Counter::setValue);
It does not use SIGNAL/SLOT macros, instead it uses function pointers.
-
The signals and slots chapter might be of interest.
-
Thanks, that was a misunderstanding from my side.
When I use the following code:
m_sslSocket->connectToHostEncrypted(m_ServerTCPIPAddress, m_ServerTCPIPPort);
to start the SSL Communication, I do not get a "encrypted(void)" event.
But when I use the following lines
m_sslSocket->connectToHostEncrypted(m_ServerTCPIPAddress, m_ServerTCPIPPort); m_sslSocket->waitForEncrypted(-1);
I will get the "encrypted(void)" event. Additional line "waitForEncrypted(-1);", will start my communication. Why ?
I am using the following signals for the communication
connect(m_sslSocket,SIGNAL(disconnected(void)), this,SLOT(disconnected(void))); connect(m_sslSocket,SIGNAL(hostFound(void)), this,SLOT(hostFound(void))); connect(m_sslSocket,SIGNAL(encrypted(void)), this, SLOT(SSLReady(void))); connect(m_sslSocket,SIGNAL(connected(void)), this,SLOT(connected(void))); typedef void (QSslSocket::* sslErrorsSignal)(const QList<QSslError> &); connect(m_sslSocket, static_cast<sslErrorsSignal>(&QSslSocket::sslErrors),this, &DataThread::SSLError); connect(m_sslSocket,SIGNAL(readyRead(void)), this,SLOT(readyRead(void))); connect(m_sslSocket,SIGNAL(aboutToClose(void)), this,SLOT(aboutToClose(void))); connect(m_sslSocket,SIGNAL(bytesWritten(qint64)), this,SLOT(bytesWritten(qint64)));
Where is my failure, because I wouldn't like to use the command "waitForEncrypted(-1);", because this is the reason
of the SLOTS and SIGNALS.Best regards
R. -
I don't see a good reason for that.
Can you provide a minimal compilable example that shows the behaviour ?
-
@SGaist
Hi,Try the following, maybe You can understand the problem.
Download the sample ssl application from here
https://github.com/GuiTeK/Qt-SslServerModify the file "ClientExample.h"
public slots: void run(); void SSLReady(void); <-------- Add this line
Add the following function file "ClientExample.cpp"
void ClientExample::SSLReady(void) { qDebug() << "SSL Ready Connected"; }
Modify the void ClientExample::run()
connect(&sslSocket,SIGNAL(encrypted(void)), this, SLOT(SSLReady(void))); <---- Add // QThread::msleep(2000); // if (sslSocket.isEncrypted()) // Wait until encrypted connection is established, -1 means no timeout if (sslSocket.waitForEncrypted(-1)) // Wait until encrypted connection is established, -1 means no timeout { qDebug() << "isEncrypted Connected";
Remove and add the "//" depending on what you would like to see
This configuration show the The of the SSLReady
// QThread::msleep(2000); // if (sslSocket.isEncrypted()) // Wait until encrypted connection is established, -1 means no timeout if (sslSocket.waitForEncrypted(-1)) // Wait until encrypted connection is established, -1 means no timeout
This does not give a connection
QThread::msleep(2000); if (sslSocket.isEncrypted()) // Wait until encrypted connection is established, -1 means no timeout // if (sslSocket.waitForEncrypted(-1)) // Wait until encrypted connection is established, -1 means no timeout
But I am not sure, if the is a good sample, but it a base code to show the problem (hopefully).
Best regards
R. -
Hi,
still working on the problem.
Is this the correct way to ignore a error, when you are using a self registered ssl certficate ?
m_sslSocket=new QSslSocket(this); m_sslSocket->addCaCertificates(ApplicationPath + "../config/" + m_LocalSSLCertificate); m_sslSocket->ignoreSslErrors();
Is this enough for disable the failure ?
How can I disable only the certification error and not all ?
Is this the correct way ?
m_sslSocket=new QSslSocket(this); m_sslSocket->addCaCertificates(ApplicationPath + "../config/" + m_LocalSSLCertificate); QList<QSslCertificate> cert = QSslCertificate::fromPath(ApplicationPath + "../config/" + m_LocalSSLCertificate); QSslError error(QSslError::SelfSignedCertificate, cert.at(0)); QList<QSslError> expectedSslErrors; expectedSslErrors.append(error); m_sslSocket->ignoreSslErrors(expectedSslErrors);
I still did not get a event in the "sslErrors" and in the "encrypted".
And I get the Messages in the DebuggerConsole
"QSslSocket: cannot resolve SSLv2_client_method" "QSslSocket: cannot resolve SSLv2_server_method"
Best regards
R. -
What are you giving exactly to
addCaCertificates
?