Create a QTcpServer and use setSocketDescriptor to pass it a socket from QSslSocket.
I do not understand where should I set:
where should I set and what for it is:Qt Code:
tcpServer->ignoreSslErrors(); QSslKey key(file, QSsl::Rsa, QSsl::Pem, QSsl::PrivateKey, "server" ); tcpServer->setPrivateKey(key); tcpServer->setLocalCertificate("server.csr");To copy to clipboard, switch view to plain text mode
Could someone write complete code? It will be faster to learn for me.Qt Code:
QSslSocket *serverSocket = new QSslSocket; if (serverSocket->setSocketDescriptor(socketDescriptor)) { connect(serverSocket, SIGNAL(encrypted()), this, SLOT(zmien())); serverSocket->startServerEncryption(); } else { delete serverSocket; }To copy to clipboard, switch view to plain text mode
There are various complete examples out there, try the Qt-interest Archive for example, or doc.trolltech.com, both of which have SSL Server examples.
You have right but example( http://doc.trolltech.com/solutions/4...r-example.html ) does not want compile because I have Qt 4.6.3, what should I do?
Alter the code so it does want compile?
If you don't understand the error messages, post them here. Perhaps someone can help.
I modified http://doc.trolltech.com/solutions/4...r-example.html (see attachments)
I am compaling typing: "qmake && make" and I see:
What have to I correct?Qt Code:
sslserver.cpp:22:33: error: ‘Server’ is not a member of ‘QSslSocket’ sslserver.cpp:23:17: error: ‘class QSslSocket’ has no member named ‘socket’ sslserver.cpp:24:17: error: ‘class QSslSocket’ has no member named ‘setPathToCertificate’ sslserver.cpp:25:17: error: ‘class QSslSocket’ has no member named ‘setPathToPrivateKey’ sslserver.cpp:29:17: error: ‘class QSslSocket’ has no member named ‘setPathToCACertDir’ sslserver.cpp:41:17: error: ‘class QSslSocket’ has no member named ‘sslAccept’ sslserver.cpp: In member function ‘void SSLServerConnection::connectionClosed()’: sslserver.cpp:152:21: error: ‘class QSslSocket’ has no member named ‘socket’ sslserver.cpp:153:29: error: ‘class QSslSocket’ has no member named ‘socket’ make: *** [sslserver.o] Błąd 1To copy to clipboard, switch view to plain text mode
I would start with using method calls that actually exist. I have no idea where did you take that code from but it makes no sense - you are calling non-existing enums methods and even if they existed, they wouldn't work as you expect them to.
It is not my code. I try compile example. I could not understand why compiler do not see "socket".
Maybe I do something wrong, I will start from original code. When I compile this: http://doc.trolltech.com/solutions/4...r-example.html I have:
Qt Code:
WARNING: /home/szarek/praca_inzynierska/temp/sslserver/sslserver.pro:5: Unable to find file for inclusion ../../src/qtsslsocket.pri sslserver.h:24:28: fatal error: qtcpserver.h: Nie ma takiego pliku ani katalogu(There is no such file or directory) compilation terminated. make: *** [main.o] Błąd 1To copy to clipboard, switch view to plain text mode
This example is not compatible with current Qt releases, it uses an outdated addition to Qt that since several months is incorporated into Qt. I suggest you turn to a "what I want to achieve" approach instead of "where do I find an example and how do I modify it to do what I want" one.
Bookmarks