Results 1 to 20 of 22

Thread: QSslsocket and Unknown error

Hybrid View

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

    Default QSslsocket and Unknown error

    I wrote that code:
    Server:
    Qt Code:
    1. //H
    2.  
    3. #ifndef POLACZENIESSL_H
    4. #define POLACZENIESSL_H
    5. #include <QTcpServer>
    6. #include <QTcpSocket>
    7. #include <QSslSocket>
    8. #include <QFile>
    9. #include <QSslKey>
    10. #include <QAbstractSocket>
    11. class PolaczenieSSL : public QTcpServer
    12. {
    13. Q_OBJECT
    14. public:
    15. PolaczenieSSL(QWidget *parent = 0);
    16. ~PolaczenieSSL();
    17. private:
    18. void incomingConnection(int port);
    19. private slots:
    20. void gotowy();
    21. };
    22.  
    23. #endif // POLACZENIESSL_H
    24.  
    25. //CPP
    26.  
    27. #include "polaczeniessl.h"
    28.  
    29. PolaczenieSSL::PolaczenieSSL(QWidget *parent)
    30. {
    31.  
    32. }
    33. PolaczenieSSL::~PolaczenieSSL()
    34. {
    35.  
    36. }
    37. void PolaczenieSSL::incomingConnection(int port)
    38. {
    39. qDebug()<<"incomingConnection";
    40. QSslSocket *serverSocket = new QSslSocket;
    41. serverSocket->setProtocol(QSsl::AnyProtocol);
    42. serverSocket->ignoreSslErrors();
    43. QFile *file = new QFile("server.key");
    44. QSslKey key(file, QSsl::Rsa, QSsl::Pem, QSsl::PrivateKey, "server");
    45. serverSocket->setPrivateKey(key);
    46. serverSocket->setLocalCertificate("server.csr");
    47. serverSocket->addCaCertificates("/etc/ssl/certs");
    48. if (serverSocket->setSocketDescriptor(port))
    49. {
    50. connect(serverSocket, SIGNAL(encrypted()), this, SLOT(gotowy()));
    51. serverSocket->startServerEncryption();
    52. qDebug()<<serverSocket->errorString();
    53.  
    54. }
    55. else
    56. {
    57. delete serverSocket;
    58. }
    59. }
    60.  
    61. void PolaczenieSSL::gotowy()
    62. {
    63. qDebug()<<"gotowy";
    64. }
    To copy to clipboard, switch view to plain text mode 
    On console, when client started connection:
    Qt Code:
    1. incomingConnection
    2. "Unknown error"
    To copy to clipboard, switch view to plain text mode 

    What is it wrong?

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

    Default Re: QSslsocket and Unknown error

    Please provide a minimal compilable example reproducing the problem. By the way, I suggest you don't call client socket as "serverSocket" and socket as "port", it leads to confusion.
    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.


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

    Default Re: QSslsocket and Unknown error

    In attachments are code. Next time, I will better use name for variables :-)
    Attached Files Attached Files

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

    Default Re: QSslsocket and Unknown error

    The project is missing some files. And based on the code I see I don't think that's a minimal example meant to reproduce a problem but rather your complete project.
    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: QSslsocket and Unknown error

    I do not understand what is for you "minimal example". File "Polaczenie" I have but a can not publish him on forum because is limit 5 attachments in one post. Can you help me with what I published?

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

    Default Re: QSslsocket and Unknown error

    Quote Originally Posted by szarek View Post
    I do not understand what is for you "minimal example".
    A minimal amount of code unrelated to your project that suffers from the same problem as your project. It is usually assembled by stripping down everything unrelated to the problem from your project and then eliminating pieces of code until the code starts working. Then you'll have your minimal example.

    File "Polaczenie" I have but a can not publish him on forum because is limit 5 attachments in one post.
    Then compress everything into single archive (zip or tar.gz).

    Can you help me with what I published?
    How can I help if I can't reproduce the problem?
    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.


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

    Default Re: QSslsocket and Unknown error

    I think it will all to reproduce problem. It will run on QtCreator 2.0,on Linux
    Attached Files Attached Files

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

    Default Re: QSslsocket and Unknown error

    You are using ignoreSslErrors() incorrectly, that's for sure but the real problem is elsewhere.

    You are calling:
    Qt Code:
    1. qDebug()<<serverSocket->errorString();
    To copy to clipboard, switch view to plain text mode 
    And my question is, what would you expect to get as a result of this method for a connection without errors? I can tell you errorString() returns a textual description of QAbstractSocket::SocketError, so the real question is what value of QAbstractSocket::SocketError would you like to receive for a connection without errors?
    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.


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

    Default Re: QSslsocket and Unknown error

    I did not think it "ignore" = "do not inform". When I comment line: "serverSocket->ignoreSslErrors();" I get that same result: "Unknown error".

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

    Default Re: QSslsocket and Unknown error

    Quote Originally Posted by szarek View Post
    I did not think it "ignore" = "do not inform". When I comment line: "serverSocket->ignoreSslErrors();"
    This is unrelated to your original "problem", I just say you are using the method incorrectly (it's a no-op in your case). This method should be used as a result of emitting an sslErrors() signal to clear the errors (i.e. untrusted certificate error) and allow the connection to continue.

    I get that same result: "Unknown error".
    Please answer my question. What result would you expect to get?
    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: QSslsocket and Unknown error

    Please, Can we talk about problem? I want to encrypt connection but signal "encrypted" is not working and I do not know why. Is this emit necessary? If yes, how this write?

  12. #12
    Join Date
    Feb 2010
    Posts
    68
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    8

    Default Re: QSslsocket and Unknown error

    Quote Originally Posted by wysota View Post
    You are using ignoreSslErrors() incorrectly, that's for sure
    Wysota, you're probably right but why then the Qt documentation says:
    "If an error occurs, QSslSocket emits the sslErrors() signal. In this case, if no action is taken to ignore the error(s), the connection is dropped. To continue, despite the occurrence of an error, you can call ignoreSslErrors(), either from within this slot after the error occurs, or any time after construction of the QSslSocket and before the connection is attempted."

Similar Threads

  1. Unknown problem
    By theMVP in forum Newbie
    Replies: 3
    Last Post: 2nd July 2010, 05:50
  2. QimageReader Unknown Error
    By bhaskar in forum Newbie
    Replies: 1
    Last Post: 2nd June 2010, 09:24
  3. Mysterious QSslSocket error causes installation to fail on Ubuntu 64-bit.
    By spitfirejunky in forum Installation and Deployment
    Replies: 2
    Last Post: 2nd April 2010, 00:04
  4. Replies: 2
    Last Post: 15th February 2010, 07:42
  5. "unknown test function error" with MAc
    By tommy in forum Installation and Deployment
    Replies: 2
    Last Post: 22nd August 2008, 19:25

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
  •  
Qt is a trademark of The Qt Company.