[Interest] Example SSL Server based on Qt...

BRM bm_witness at yahoo.com
Thu Jan 7 16:20:31 CET 2016


There's plenty of examples of HTTP servers. The example of a Qt SSL Server provided by Qt is a QWebSockets server - but that doesn't help much for a generic use of SSL connections like what (and apparently others) wanted that is apart from HTTP or Web Sockets. My basic requirement is using SSL socket to encrypt the traffic between my client and server without having to deal with those details myself.

Ben

    On Thursday, January 7, 2016 5:57 AM, Emre Besirik <nomercy at gmail.com> wrote:
 

 There is already a http(s) server written with/for qt in case you missed it on google…
http://www.stefanfrings.de/qtwebapp/index-en.html
Regards/Saygilar,Emre Beşiriknomercy at gmail.com



On 07 Jan 2016, at 07:16, BRM via Interest <interest at qt-project.org> wrote:
Thanks for the feedback. Advice and direction on this is welcome.
I'm not sure if I'll move it towards the official Qt coding style or not - though I'd probably accept PRs that did. I just found in trying to put together the server for another project that there were no server-side Qt SSL examples out there - and it was a common complaint in the various forums I came across while searching. So I made one. I'll be the first to admit as an example it could certainly be cleaned up more; but it's still better than nothing (which is where we were before). There were some choices I made just to try to keep it simple or towards being an example - I think some of them (like the certificate verification) are commented on (or at least should be) in the code.
I'll certainly try to clean some things up to make it even simpler; and I'll take a look at using the QPluginLoader with it....that's an interesting idea.

Thanks for the advice.

Ben
 

    On Wednesday, January 6, 2016 6:54 PM, Jason H <jhihn at gmx.com> wrote:
 

 Don't take this the wrong way...  I've written production-level HTTP SSL servers in Qt before, and I've even requested/suggested there be a Qt C++ server framework. So take this as advice from a veteran. Well, you should use QCoreApplication (drop the GUI), you never call startSeverEncrption(), never set the validation policy of certificates, and never actually read or write anything from the client, don't have any socket timeouts. Other than that, it's a great server. :-) (My snarkiness is intended to be mild-mannered). Code wise, it's not following the Qt style guide and IMHO, makes superfluous use of namespaces.  If this is to be for HTTP, there are many, many more challenges. The problem is the C++ nature usually results in a a bespoke server app. However, I think that if there were a server to use QPluginLoader, where your application was presented as a shared library and it register itself, we'd be able to get some traction. These days it's just easier/faster with NodeJS, and Node is JITed. After doing that, the challenge is then constructing a framework to handle _ALL_ the possible scenarios. LibQxt took a decent stab at it. ( http://libqxt.bitbucket.org/doc/0.6/tech-web.html ) If you're not doing HTTP, then you're much better off, but then you limit your clients and have to some up with your own serialization. Things to worry about include encodings (base64, gzip), chunked transfer encoding (content length not known at start of transfer), and I hope multi-part mime attachments are not needed. A good primer for low-level HTTP is https://www.jmarshall.com/easy/http/ I found using many QIODevice subclasses which relayed data bytes and emitted events worked best, in that one source of bytes relays applicable bytes to the next, Like:QSslSocket -> HttpRequestParser -> TransferEncoding -> MIME parser -> MimePartParser -> EncodingParser(s) -> ApplicationDataHandlers. (NodeJS calls this 'middleware')Your response is similarly complicated because you may be using chunked encoding, HTTP1.1, gzip all independently of each other. Then adding to that, it's all got to happen async if it is to be general purpose. (That's why the emits are nice) . Once those are handled, I always imagined some JSON config file(s): { file: "myapp.so", [{path: "/login", function: "some_Q_INVOKABLE(request, response)"}, ...] } } It'll be much easier today than when I was doing it, as there weren't attached properties in Qt back then (2008).  Just my $0.02 Sent: Wednesday, January 06, 2016 at 4:50 PM
From: "BRM via Interest" <interest at qt-project.org>
To: "Interests Qt" <interest at qt-project.org>
Subject: [Interest] Example SSL Server based on Qt...Over the holidays I started working on a project where I wanted to use Qt's SSL Sockets for a client-server system.Looking around, I didn't find an example of using them on the *server* side, and the Qt Documentation just provides *client* side examples.So, I pulled some parts out of my project and setup an example - you can find it here: https://github.com/BenjamenMeyer/ExampleQtSSL I posted this on G+ after pushing it up; however, I figured others here might be interested in this example as well. Presently the example is a simple 3 part project consisting of (i) client, (ii) server, and (iii) common static library between the two.The client and server both operate as GUI programs with a simple text display to show what is going on, as well as a basic file log for more extensive diagnostics. PR's welcome if anyone wants to help make it even better. I'll probably make a daemonized version of the service at some point. Ben_______________________________________________ Interest mailing list Interest at qt-project.org http://lists.qt-project.org/mailman/listinfo/interest

   _______________________________________________
Interest mailing list
Interest at qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest




  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20160107/2e3b303e/attachment.html>


More information about the Interest mailing list