Results 1 to 14 of 14

Thread: examples and Ssl

  1. #1
    Join Date
    Jun 2010
    Posts
    21
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default examples and Ssl

    I want to learn how to use encryption using QSslsocket but it is to hard to me with out example. I know about Secure socket client but it is only client. I want to ask for write complet code changing: http://doc.qt.nokia.com/4.6/network-fortuneclient.html and http://doc.qt.nokia.com/4.6/network-fortuneserver.html

  2. #2
    Join Date
    Sep 2009
    Location
    UK
    Posts
    2,447
    Thanks
    6
    Thanked 348 Times in 333 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: examples and Ssl


  3. #3
    Join Date
    Jun 2010
    Posts
    21
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: examples and Ssl

    Quote Originally Posted by fatjuicymole View Post
    Thank you for your respond. It is perfect example for client but where is code for server?

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,360
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: examples and Ssl

    Create a QTcpServer and use setSocketDescriptor to pass it a socket from QSslSocket.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  5. #5
    Join Date
    Jun 2010
    Posts
    21
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: examples and Ssl

    Quote Originally Posted by wysota View Post
    Create a QTcpServer and use setSocketDescriptor to pass it a socket from QSslSocket.
    I do not understand where should I set:
    Qt Code:
    1. tcpServer->ignoreSslErrors();
    2. QFile *file = new QFile("server.key");
    3. QSslKey key(file, QSsl::Rsa, QSsl::Pem, QSsl::PrivateKey, "server" );
    4. tcpServer->setPrivateKey(key);
    5. tcpServer->setLocalCertificate("server.csr");
    To copy to clipboard, switch view to plain text mode 
    where should I set and what for it is:
    Qt Code:
    1. QSslSocket *serverSocket = new QSslSocket;
    2. if (serverSocket->setSocketDescriptor(socketDescriptor)) {
    3. connect(serverSocket, SIGNAL(encrypted()), this, SLOT(zmien()));
    4. serverSocket->startServerEncryption();
    5. } else {
    6. delete serverSocket;
    7. }
    To copy to clipboard, switch view to plain text mode 
    Could someone write complete code? It will be faster to learn for me.

  6. #6
    Join Date
    Sep 2009
    Location
    UK
    Posts
    2,447
    Thanks
    6
    Thanked 348 Times in 333 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: examples and Ssl

    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.

  7. #7
    Join Date
    Jun 2010
    Posts
    21
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: examples and Ssl

    Quote Originally Posted by fatjuicymole View Post
    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?

  8. #8
    Join Date
    Sep 2009
    Location
    UK
    Posts
    2,447
    Thanks
    6
    Thanked 348 Times in 333 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: examples and Ssl

    Alter the code so it does want compile?

    If you don't understand the error messages, post them here. Perhaps someone can help.

  9. #9
    Join Date
    Jun 2010
    Posts
    21
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: examples and Ssl

    I modified http://doc.trolltech.com/solutions/4...r-example.html (see attachments)

    I am compaling typing: "qmake && make" and I see:
    Qt Code:
    1. sslserver.cpp: In constructor ‘SSLServerConnection::SSLServerConnection(quint16, QObject*)’:
    2. sslserver.cpp:22:33: error: ‘Server’ is not a member of ‘QSslSocket’
    3. sslserver.cpp:23:17: error: ‘class QSslSocket’ has no member named ‘socket’
    4. sslserver.cpp:24:17: error: ‘class QSslSocket’ has no member named ‘setPathToCertificate’
    5. sslserver.cpp:25:17: error: ‘class QSslSocket’ has no member named ‘setPathToPrivateKey’
    6. sslserver.cpp:29:17: error: ‘class QSslSocket’ has no member named ‘setPathToCACertDir’
    7. sslserver.cpp:41:17: error: ‘class QSslSocket’ has no member named ‘sslAccept’
    8. sslserver.cpp: In member function ‘void SSLServerConnection::connectionClosed()’:
    9. sslserver.cpp:152:21: error: ‘class QSslSocket’ has no member named ‘socket’
    10. sslserver.cpp:153:29: error: ‘class QSslSocket’ has no member named ‘socket’
    11. make: *** [sslserver.o] BÅ‚Ä…d 1
    To copy to clipboard, switch view to plain text mode 
    What have to I correct?
    Attached Files Attached Files

  10. #10
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,360
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: examples and Ssl

    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.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  11. #11
    Join Date
    Jun 2010
    Posts
    21
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: examples and Ssl

    It is not my code. I try compile example. I could not understand why compiler do not see "socket".

  12. #12
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,360
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: examples and Ssl

    Quote Originally Posted by szarek View Post
    I try compile example.
    What example? Please point me to an example that claims QSslSocket has a constructor like the one you are calling in your code.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  13. #13
    Join Date
    Jun 2010
    Posts
    21
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: examples and Ssl

    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:
    1. WARNING: /home/szarek/praca_inzynierska/temp/sslserver/sslserver.pro:5: Unable to find file for inclusion ../../src/qtsslsocket.pri
    2. sslserver.h:24:28: fatal error: qtcpserver.h: Nie ma takiego pliku ani katalogu(There is no such file or directory)
    3. compilation terminated.
    4. make: *** [main.o] BÅ‚Ä…d 1
    To copy to clipboard, switch view to plain text mode 

  14. #14
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,360
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: examples and Ssl

    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.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. Qwt examples
    By nitriles in forum Qwt
    Replies: 7
    Last Post: 6th August 2011, 04:07
  2. source for examples
    By wagmare in forum General Discussion
    Replies: 0
    Last Post: 6th January 2009, 09:22
  3. Qwt examples
    By 31512 in forum Qwt
    Replies: 11
    Last Post: 3rd July 2008, 05:00
  4. QCanvas Examples
    By Kapil in forum Qt Programming
    Replies: 6
    Last Post: 23rd March 2006, 13:12
  5. Qt 3.x Examples
    By ball in forum Qt Programming
    Replies: 2
    Last Post: 11th January 2006, 13:44

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.