diff options
author | BogDan Vatra <bogdan@kdab.com> | 2018-07-02 15:41:24 +0200 |
---|---|---|
committer | BogDan Vatra <bogdan@kdab.com> | 2018-10-29 06:20:35 +0000 |
commit | 88673b336fd52c026134d1e348d12c310c48b1ac (patch) | |
tree | c0c59a79773d0a6b4eb3baeb9dfaefe2fcbc0d8f /tests | |
parent | e8f49d3bf0557cc3c1b1e0358bed720023fdc2b4 (diff) |
Add SSL example & auto test
Change-Id: I3342507fa2ea69f753f1f062c233211fad4791ff
Reviewed-by: Brett Stottlemyer <bstottle@ford.com>
Diffstat (limited to 'tests')
19 files changed, 578 insertions, 1 deletions
diff --git a/tests/auto/auto.pro b/tests/auto/auto.pro index 1627198..f80bdb2 100644 --- a/tests/auto/auto.pro +++ b/tests/auto/auto.pro @@ -19,7 +19,8 @@ SUBDIRS += \ repparser \ subclassreplica \ sub_integration \ - sub_localsockettestserver + sub_localsockettestserver \ + external_IODevice qtHaveModule(qml): SUBDIRS += qml qtConfig(process): SUBDIRS += integration_multiprocess integration_external diff --git a/tests/auto/external_IODevice/cert/cert.qrc b/tests/auto/external_IODevice/cert/cert.qrc new file mode 100644 index 0000000..65f92e2 --- /dev/null +++ b/tests/auto/external_IODevice/cert/cert.qrc @@ -0,0 +1,11 @@ +<RCC> + <qresource prefix="/sslcert"> + <file>client.crt</file> + <file>client.key</file> + <file>rootCA.key</file> + <file>rootCA.pem</file> + <file>rootCA.srl</file> + <file>server.crt</file> + <file>server.key</file> + </qresource> +</RCC> diff --git a/tests/auto/external_IODevice/cert/client.crt b/tests/auto/external_IODevice/cert/client.crt new file mode 100644 index 0000000..e8c8c14 --- /dev/null +++ b/tests/auto/external_IODevice/cert/client.crt @@ -0,0 +1,18 @@ +-----BEGIN CERTIFICATE----- +MIIC8jCCAdoCCQDPkkFD8ish3zANBgkqhkiG9w0BAQsFADAxMQswCQYDVQQGEwJV +UzEPMA0GA1UECAwGT3JlZ29uMREwDwYDVQQHDAhQb3J0bGFuZDAeFw0xODA3MDMw +OTMyNTFaFw0yMzA3MDIwOTMyNTFaMEUxCzAJBgNVBAYTAlVTMQ8wDQYDVQQIDAZP +cmVnb24xETAPBgNVBAcMCFBvcnRsYW5kMRIwEAYDVQQDDAkxMjcuMC4wLjEwggEi +MA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDexH8hCVisI6sHb7o2nK3kMuwT +DEBoQesEqZsfypiwOYkB2OqzW3HmFfDeUVKBGBJk07QPYM1v9ocaEbYFkAOpj1hH +Gl02DihWqMqbFdwugV/z6dwo8r7ZOsCYhDeAhtXKbAX2ASGdlHusY9lIHRqGrlm3 +veHJrdXUAQAYHyI7XrinLV8RNCMDI3CVhcNEOc3C3AyufcXUZ1cEGAYDPXGtwPEd +RFQQBbyYSQ4RgR2BlPkPE1VQiE01cDFMF8RNaQL89uhJkMruano+7eTawax1h8q4 +D2LK9sRPRtz7Zivx3Z2Vk9I7suX9C2RhuSgzHiXWuP7VBVcJiAL/GICoq9bJAgMB +AAEwDQYJKoZIhvcNAQELBQADggEBABy/ofQyVtXNZ6thyU+M41m3nb2DFayFimjm +wPcbgXR/EPyZrP2I1O8FZh7KlICg97kqPsN4CvVU6n9KVmM3EVzwNcPuwr0ufXHF +nq/lrVvy0osNh8KzN8jpHZ8Dsl4XXnXAKh4oxCRVB+R4FVirBTAQiu7OUFk+s7I5 +hoXI47whP7sOmxB+2YbVFPSTj26pupssMHCDoxAXC36ARH/68itdX2LQ5iLoqzEI +PNxuLY3fFEGnu0ymZUMuevIbD4tAZiIlw17gr683pwNCuEvKAyNoehLnknXIILs5 +pVx3XcS6vw5+IbQb+HdxT/RPm6U4fIZVFdoC2o/x1G8wzPJvW/0= +-----END CERTIFICATE----- diff --git a/tests/auto/external_IODevice/cert/client.key b/tests/auto/external_IODevice/cert/client.key new file mode 100644 index 0000000..75e1f43 --- /dev/null +++ b/tests/auto/external_IODevice/cert/client.key @@ -0,0 +1,27 @@ +-----BEGIN RSA PRIVATE KEY----- +MIIEpQIBAAKCA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AoGAWgMzQap6BwILeD2Z730N +b7DyhMVDNkMAlRKjVnMYciF03uEEgXZqsGVG3MAkLdQtCwSaWDeH0jA//e9iCkYy +/0Z+PZGnakCQkIYdejwiIJvGzaSkM8gX5bBteO9SMpsW0cAZYzm6UkudDi0R3cxE +r10oQZxd2VPz/jDGYPvUpgECgYEAvT1+SksT0+rrdUly6/mfHVKqvxIq4gfinPhq +dolCq6Hglm76eGW3yZ+U1tgpupULGbfyTWyqvRVjSb1GE1HRpTEMxBGpCHw0i1zq +5pcNN8VfZoH/73zbbA5a09EEetaTIQKL3IT6+BYi8zYv1H0UQshPNNHEZx2zDmPx +z9ZpJrECgYEAmxsv/6LNyV5+h8WOdyHtNFF04jo1s9CfRc0fMkKVQNZVaOu3sgLZ +B4r2XrK75S19iJj4AVxf7dP3EbblDXvnQhlLV8IcYuULDovdXvYJrkv2a0KQ5nqO +mt8brk85kb/GW8MrYHwLeFYSytZk267osPlwzIW1Zr9pDpARSVXer98= +-----END RSA PRIVATE KEY----- diff --git a/tests/auto/external_IODevice/cert/rootCA.key b/tests/auto/external_IODevice/cert/rootCA.key new file mode 100644 index 0000000..4603898 --- /dev/null +++ b/tests/auto/external_IODevice/cert/rootCA.key @@ -0,0 +1,27 @@ +-----BEGIN RSA PRIVATE KEY----- +MIIEogIBAAKCAQEAnFgYQwg4xeA2yYnWZ0TqZCEBlzg2zbi0ToeO3msOYI7m6urI +/gUp3uezK/5bO9xVudRYq9qbK/1XmAhD+oILxVFY8VHO9p7xGVav2T8cPtFUkj05 +9WT7TDlOwEIOyb7WbEjLE1a0u9Iyl6Ju7VwCf0xijtD8TomB41PojNe49G1JN5CK +AdkCYyrgjCBj13iZo9VFp/xWWTfk6iPa928AavYYUWHizAc3Kvr46DGW9pIjPthH +EC6dmiX0oHfLF8HcTvgL/pHzF2bT5grYoARwIectD996z8smrsN7clfjMHwDHH8a +OCgIvNNOs4jWSu6oXqEwvGyRxmsHFi1jbhHNkwIDAQABAoIBADmSQxTkASv0f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I1mXtCF/AXYdgdpLxwP1mtevfxt7j65CPQYOQK4ceu54Ka48+8 +2TkmC/WjyWtM1YJZtArJsFBGYcX4WoVtGCU1Mbl19+1vKQMb1dlOC0HqU0c9UCcu +fD6y4coCLXemKOJ32sHMdy8qyFxOz2CrznZa4uYBT4Lid8SY+yY= +-----END RSA PRIVATE KEY----- diff --git a/tests/auto/external_IODevice/cert/rootCA.pem b/tests/auto/external_IODevice/cert/rootCA.pem new file mode 100644 index 0000000..6f3f886 --- /dev/null +++ b/tests/auto/external_IODevice/cert/rootCA.pem @@ -0,0 +1,20 @@ +-----BEGIN CERTIFICATE----- +MIIDODCCAiCgAwIBAgIJAJDf3heNbfP6MA0GCSqGSIb3DQEBCwUAMDExCzAJBgNV +BAYTAlVTMQ8wDQYDVQQIDAZPcmVnb24xETAPBgNVBAcMCFBvcnRsYW5kMB4XDTE4 +MDcwMzA5MzI1MFoXDTIzMDcwMjA5MzI1MFowMTELMAkGA1UEBhMCVVMxDzANBgNV +BAgMBk9yZWdvbjERMA8GA1UEBwwIUG9ydGxhbmQwggEiMA0GCSqGSIb3DQEBAQUA +A4IBDwAwggEKAoIBAQCcWBhDCDjF4DbJidZnROpkIQGXODbNuLROh47eaw5gjubq +6sj+BSne57Mr/ls73FW51Fir2psr/VeYCEP6ggvFUVjxUc72nvEZVq/ZPxw+0VSS +PTn1ZPtMOU7AQg7JvtZsSMsTVrS70jKXom7tXAJ/TGKO0PxOiYHjU+iM17j0bUk3 +kIoB2QJjKuCMIGPXeJmj1UWn/FZZN+TqI9r3bwBq9hhRYeLMBzcq+vjoMZb2kiM+ +2EcQLp2aJfSgd8sXwdxO+Av+kfMXZtPmCtigBHAh5y0P33rPyyauw3tyV+MwfAMc +fxo4KAi8006ziNZK7qheoTC8bJHGawcWLWNuEc2TAgMBAAGjUzBRMB0GA1UdDgQW +BBRFDBFImjfGGcuUO2yGvXFtkj+tATAfBgNVHSMEGDAWgBRFDBFImjfGGcuUO2yG +vXFtkj+tATAPBgNVHRMBAf8EBTADAQH/MA0GCSqGSIb3DQEBCwUAA4IBAQCbBnbX +ms5mFTaPJislt+8A7c/HKz5S5U2jg4+5Nh7b7szbG3s/AGDuSwEQDRAU5J8gqb1r +IkmrkZA3C8mEY/NLzDjbbW+T0z7zlXFXWKZmzhx+ROONys1HGKwNRe/oa9cAJnbv +KeMfruIXeSTf6U9tehUdoEk87eTAONm4PtVgE4aenSxaIdT7dXlzYBzhCFzsXH/y +VyNQD0wd7u+L6av+zRod7Sz7WU/Lnhi1fQXcFmmAmmmCHyctI0xgwdRB9O80ls8s +Ea+0J9Mkt07YTKcG1ZpmJHU915M/aDDpV/2RGcYGLOHOrD1IT8Cl3ZwHGlERI3y6 ++GFPhQzo4mXu3pdb +-----END CERTIFICATE----- diff --git a/tests/auto/external_IODevice/cert/rootCA.srl b/tests/auto/external_IODevice/cert/rootCA.srl new file mode 100644 index 0000000..8888354 --- /dev/null +++ b/tests/auto/external_IODevice/cert/rootCA.srl @@ -0,0 +1 @@ +CF924143F22B21E0 diff --git a/tests/auto/external_IODevice/cert/server.crt b/tests/auto/external_IODevice/cert/server.crt new file mode 100644 index 0000000..0587867 --- /dev/null +++ b/tests/auto/external_IODevice/cert/server.crt @@ -0,0 +1,18 @@ +-----BEGIN CERTIFICATE----- +MIIC7zCCAdcCCQDPkkFD8ish4DANBgkqhkiG9w0BAQsFADAxMQswCQYDVQQGEwJV +UzEPMA0GA1UECAwGT3JlZ29uMREwDwYDVQQHDAhQb3J0bGFuZDAeFw0xODA3MDMw +OTMyNTFaFw0yMzA3MDIwOTMyNTFaMEIxCzAJBgNVBAYTAlVTMQ8wDQYDVQQIDAZP +cmVnb24xDjAMBgNVBAcMBVNhbGVtMRIwEAYDVQQDDAkxMjcuMC4wLjEwggEiMA0G +CSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQC1zm/3QDUh1FhAczb7zDzme2Ncgs3x +26RNMCS+DKQS8mf4tuyBT/62Ba8pMgOi46hS2/7BKbCFlU3F4rZiz/2y50fs5m0z +Puf9sB6xGrya4hzLS7gML7QbP3gXvmWSYRGLT4kpK7Cf58nK9P8NWbgzcX95bjlV +QDyUdLNy9wnH5xuumdIk7Il4EmSjWyL7N5PtEpfgvG79DAh8AiWvVWKgddVbkAUy +s4kI+2LJ3NKfLGqh0ijY00a6KD7wuAAyws5EqQQ3/BYDf6/dSRXRMED/0gg1XPF5 +7VtTDltwneelfVI1SBhgHTE5ynN0WiTP5LaVPs6jQPJXNslvbWWbyngNAgMBAAEw +DQYJKoZIhvcNAQELBQADggEBAEGGolgL7wv4NwuAfFA0fPu6VZOfqgqw3g5M2gpw +7+XcUSWdum/8yUxkeaI5fLSA3sq6PefLaMpZ7+2JQYKJZZ4zl3fJ5D1M/VMQOQ1Q +PAMzGjHNZ7T0vs5F5TdpbXpEbvcBvLz/k2FRMs2Z/WBQZQITEiQ1wf91jxc4dQr5 +nM6CN0TUW8wCKOi+8QXruUnHnaPreRh68A2FfnGSBJlkImhkFjAMtIdpkAHTiNs+ +PE/Dx58wsrnY6DiZfYPrKj54TkdnoKpWCLarxuMzeGUEvQcaXhksnRfDBc5k4ev4 +g7RhsGXyIJvFFvKVeH9GbGfgSXn7rc6Tesnzyh+mvHT3vMU= +-----END CERTIFICATE----- diff --git a/tests/auto/external_IODevice/cert/server.key b/tests/auto/external_IODevice/cert/server.key new file mode 100644 index 0000000..e9bc3a1 --- /dev/null +++ b/tests/auto/external_IODevice/cert/server.key @@ -0,0 +1,27 @@ +-----BEGIN RSA PRIVATE KEY----- +MIIEogIBAAKCAQEAtc5v90A1IdRYQHM2+8w85ntjXILN8dukTTAkvgykEvJn+Lbs +gU/+tgWvKTIDouOoUtv+wSmwhZVNxeK2Ys/9sudH7OZtMz7n/bAesRq8muIcy0u4 +DC+0Gz94F75lkmERi0+JKSuwn+fJyvT/DVm4M3F/eW45VUA8lHSzcvcJx+cbrpnS +JOyJeBJko1si+zeT7RKX4Lxu/QwIfAIlr1VioHXVW5AFMrOJCPtiydzSn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ee3yUmTRGTUZYAex/l+JI1gP4eXUvgwmjEMGPg5n +mLlqZAiW9vZSx3Al9PM+rXNbvbgF3KeaRrjAVwSlh/GC+NkgojDO7SxBZBOXmchp +t459AoGABXvsiqC8TxAyGTlnVUTNlWnWzo7Qy+DHsJUgLvEdW47oairtdvGjCWFU +dBk7qmxDNpEZ/0LrUtcgLwN/45PXOrKn0ojA86Csoij5HbsUx0c/g8bMES0ilghx +tbEtOBkXNIPgmaXdyXW203i3/oLSY1nedePIbJU22nJzQHmw0mk= +-----END RSA PRIVATE KEY----- diff --git a/tests/auto/external_IODevice/external_IODevice.pro b/tests/auto/external_IODevice/external_IODevice.pro new file mode 100644 index 0000000..e30f588 --- /dev/null +++ b/tests/auto/external_IODevice/external_IODevice.pro @@ -0,0 +1,3 @@ +TEMPLATE = subdirs +CONFIG += ordered +SUBDIRS = sslTestServer tst_client diff --git a/tests/auto/external_IODevice/pingpong.rep b/tests/auto/external_IODevice/pingpong.rep new file mode 100644 index 0000000..f981e55 --- /dev/null +++ b/tests/auto/external_IODevice/pingpong.rep @@ -0,0 +1,8 @@ +#include <QtCore> + +class PingPong +{ + SLOT(void ping(const QString &message)); + SLOT(void quit()); + SIGNAL(pong(const QString &message)); +}; diff --git a/tests/auto/external_IODevice/sslTestServer/main.cpp b/tests/auto/external_IODevice/sslTestServer/main.cpp new file mode 100644 index 0000000..45ad9cd --- /dev/null +++ b/tests/auto/external_IODevice/sslTestServer/main.cpp @@ -0,0 +1,76 @@ +/**************************************************************************** +** +** Copyright (C) 2018 Ford Motor Company +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtRemoteObjects module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "pingpong.h" +#include "sslserver.h" + +#include <QCoreApplication> +#include <QDebug> +#include <QSslConfiguration> + +#include <QRemoteObjectHost> + + +/* + To generate certificates you can use the following commands: + +openssl genrsa -out rootCA.key 2048 +openssl req -x509 -new -nodes -key rootCA.key -sha256 -days 1825 -out rootCA.pem -subj "/C=US/ST=Oregon/L=Portland" + +openssl genrsa -out client.key 2048 +openssl req -new -key client.key -out client.csr -subj "/C=US/ST=Oregon/L=Portland/CN=127.0.0.1" +openssl x509 -req -in client.csr -CA rootCA.pem -CAkey rootCA.key -CAcreateserial -out client.crt -days 1825 -sha256 + +openssl genrsa -out server.key 2048 +openssl req -new -key server.key -out server.csr -subj "/C=US/ST=Oregon/L=Salem/CN=127.0.0.1" +openssl x509 -req -in server.csr -CA rootCA.pem -CAkey rootCA.key -CAcreateserial -out server.crt -days 1825 -sha256 +*/ + +int main(int argc, char *argv[]) +{ + QCoreApplication app(argc, argv); + QRemoteObjectHost host; + auto config = QSslConfiguration::defaultConfiguration(); + config.setCaCertificates(QSslCertificate::fromPath(QStringLiteral(":/sslcert/rootCA.pem"))); + QSslConfiguration::setDefaultConfiguration(config); + SslServer server; + server.listen(QHostAddress::Any, 65111); + host.setHostUrl(server.serverAddress().toString(), QRemoteObjectHost::AllowExternalRegistration); + QObject::connect(&server, &SslServer::encryptedSocketReady, &server, [&host](QSslSocket *socket){ + QObject::connect(socket, QOverload<QAbstractSocket::SocketError>::of(&QSslSocket::error), + socket, [](QAbstractSocket::SocketError error){ + qDebug() << "QSslSocket::error" << error; + exit(1); + }); + host.addHostSideConnection(socket); + }); + + PingPong pp; + host.enableRemoting(&pp); + return app.exec(); +} diff --git a/tests/auto/external_IODevice/sslTestServer/pingpong.cpp b/tests/auto/external_IODevice/sslTestServer/pingpong.cpp new file mode 100644 index 0000000..a014103 --- /dev/null +++ b/tests/auto/external_IODevice/sslTestServer/pingpong.cpp @@ -0,0 +1,47 @@ +/**************************************************************************** +** +** Copyright (C) 2018 Ford Motor Company +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtRemoteObjects module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QCoreApplication> +#include <QDebug> +#include <QTimer> +#include "pingpong.h" + +PingPong::PingPong(QObject *parent) + : PingPongSimpleSource(parent) +{} + +void PingPong::ping(const QString &message) +{ + emit pong("Pong " + message); +} + +void PingPong::quit() +{ + // Kill me softly + QMetaObject::invokeMethod(qApp, "quit", Qt::QueuedConnection); +} diff --git a/tests/auto/external_IODevice/sslTestServer/pingpong.h b/tests/auto/external_IODevice/sslTestServer/pingpong.h new file mode 100644 index 0000000..2a7a788 --- /dev/null +++ b/tests/auto/external_IODevice/sslTestServer/pingpong.h @@ -0,0 +1,45 @@ +/**************************************************************************** +** +** Copyright (C) 2018 Ford Motor Company +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtRemoteObjects module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef PINGPONG_H +#define PINGPONG_H + +#include "rep_pingpong_source.h" + +class PingPong : public PingPongSimpleSource +{ +public: + PingPong(QObject *parent = nullptr); + + // PingPongSource interface +public slots: + void ping(const QString &message) override; + void quit() override; +}; + +#endif // PINGPONG_H diff --git a/tests/auto/external_IODevice/sslTestServer/sslTestServer.pro b/tests/auto/external_IODevice/sslTestServer/sslTestServer.pro new file mode 100644 index 0000000..a2ed034 --- /dev/null +++ b/tests/auto/external_IODevice/sslTestServer/sslTestServer.pro @@ -0,0 +1,23 @@ +TEMPLATE = app +QT += remoteobjects core testlib +QT -= gui + +TARGET = sslTestServer + +DESTDIR = ./ +CONFIG += c++11 +CONFIG -= app_bundle + +INCLUDEPATH += $$PWD + +REPC_SOURCE = $$PWD/../pingpong.rep + +RESOURCES += $$PWD/../cert/cert.qrc + +SOURCES += main.cpp \ + pingpong.cpp \ + sslserver.cpp + +HEADERS += \ + pingpong.h \ + sslserver.h diff --git a/tests/auto/external_IODevice/sslTestServer/sslserver.cpp b/tests/auto/external_IODevice/sslTestServer/sslserver.cpp new file mode 100644 index 0000000..725567c --- /dev/null +++ b/tests/auto/external_IODevice/sslTestServer/sslserver.cpp @@ -0,0 +1,57 @@ +/**************************************************************************** +** +** Copyright (C) 2018 Ford Motor Company +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtRemoteObjects module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "sslserver.h" +#include <QSslSocket> + +SslServer::SslServer(QObject *parent) + : QTcpServer(parent) +{} + + +void SslServer::incomingConnection(qintptr socketDescriptor) +{ + auto serverSocket = new QSslSocket; + if (serverSocket->setSocketDescriptor(socketDescriptor)) { + addPendingConnection(serverSocket); + connect(serverSocket, &QSslSocket::encrypted, this, [this, serverSocket] { + Q_EMIT encryptedSocketReady(serverSocket); + }); + connect(serverSocket, static_cast<void (QSslSocket::*)(const QList<QSslError>&)>(&QSslSocket::sslErrors), + this, [serverSocket](const QList<QSslError>& errors){ + qWarning() << "Error:" << serverSocket << errors; + delete serverSocket; + }); + serverSocket->setPeerVerifyMode(QSslSocket::VerifyPeer); + serverSocket->setLocalCertificate(QStringLiteral(":/sslcert/server.crt")); + serverSocket->setPrivateKey(QStringLiteral(":/sslcert/server.key")); + serverSocket->startServerEncryption(); + } else { + delete serverSocket; + } +} diff --git a/tests/auto/external_IODevice/sslTestServer/sslserver.h b/tests/auto/external_IODevice/sslTestServer/sslserver.h new file mode 100644 index 0000000..237823b --- /dev/null +++ b/tests/auto/external_IODevice/sslTestServer/sslserver.h @@ -0,0 +1,50 @@ +/**************************************************************************** +** +** Copyright (C) 2018 Ford Motor Company +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtRemoteObjects module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef SSLSERVER_H +#define SSLSERVER_H + +#include <QTcpServer> + +QT_BEGIN_NAMESPACE +class QSslSocket; +QT_END_NAMESPACE + +class SslServer : public QTcpServer +{ + Q_OBJECT +public: + SslServer(QObject *parent=nullptr); + void incomingConnection(qintptr socketDescriptor) override; + +signals: + void encryptedSocketReady(QSslSocket *socket); +}; + + +#endif // SSLSERVER_H diff --git a/tests/auto/external_IODevice/tst_client/tst_client.cpp b/tests/auto/external_IODevice/tst_client/tst_client.cpp new file mode 100644 index 0000000..826dd9b --- /dev/null +++ b/tests/auto/external_IODevice/tst_client/tst_client.cpp @@ -0,0 +1,106 @@ +/**************************************************************************** +** +** Copyright (C) 2018 Ford Motor Company +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtRemoteObjects module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QtTest/QtTest> +#include <QRemoteObjectNode> +#include <QScopedPointer> +#include "rep_pingpong_replica.h" + +namespace { + +QString findExecutable(const QString &executableName, const QStringList &paths) +{ + const auto path = QStandardPaths::findExecutable(executableName, paths); + if (!path.isEmpty()) { + return path; + } + + qWarning() << "Could not find executable:" << executableName << "in any of" << paths; + return QString(); +} + +} + +class tst_clientSSL: public QObject +{ + Q_OBJECT +public: + tst_clientSSL() = default; + +private slots: + void testRun() + { + QProcess serverProc; + serverProc.setProcessChannelMode(QProcess::ForwardedChannels); + serverProc.start(findExecutable("sslTestServer", { + QCoreApplication::applicationDirPath() + "/../sslTestServer/" + })); + QVERIFY(serverProc.waitForStarted()); + + // wait for server start + QTest::qWait(200); + QRemoteObjectNode m_client; + auto config = QSslConfiguration::defaultConfiguration(); + config.setCaCertificates(QSslCertificate::fromPath(QStringLiteral(":/sslcert/rootCA.pem"))); + QSslConfiguration::setDefaultConfiguration(config); + + QScopedPointer<QSslSocket> socketClient{new QSslSocket}; + socketClient->setLocalCertificate(QStringLiteral(":/sslcert/client.crt")); + socketClient->setPrivateKey(QStringLiteral(":/sslcert/client.key")); + socketClient->setPeerVerifyMode(QSslSocket::VerifyPeer); + socketClient->connectToHostEncrypted(QStringLiteral("127.0.0.1"), 65111); + QVERIFY(socketClient->waitForEncrypted(-1)); + + connect(socketClient.data(), QOverload<QAbstractSocket::SocketError>::of(&QSslSocket::error), + socketClient.data(), [](QAbstractSocket::SocketError error){ + QCOMPARE(error, QAbstractSocket::RemoteHostClosedError); + }); + m_client.addClientSideConnection(socketClient.data()); + + QScopedPointer<PingPongReplica> pp{m_client.acquire<PingPongReplica>()}; + QVERIFY(pp->waitForSource()); + + QString pongStr; + connect(pp.data(), &PingPongReplica::pong, [&pongStr](const QString &str) { + pongStr = str; + }); + pp->ping("yahoo"); + QTRY_COMPARE(pongStr, "Pong yahoo"); + pp->ping("one more"); + QTRY_COMPARE(pongStr, "Pong one more"); + pp->ping("last one"); + QTRY_COMPARE(pongStr, "Pong last one"); + pp->quit(); + QTRY_VERIFY(serverProc.state() != QProcess::Running); + QCOMPARE(serverProc.exitCode(), 0); + } +}; + +QTEST_MAIN(tst_clientSSL) + +#include "tst_client.moc" diff --git a/tests/auto/external_IODevice/tst_client/tst_client.pro b/tests/auto/external_IODevice/tst_client/tst_client.pro new file mode 100644 index 0000000..ceed3e5 --- /dev/null +++ b/tests/auto/external_IODevice/tst_client/tst_client.pro @@ -0,0 +1,12 @@ +CONFIG += testcase c++11 +CONFIG -= app_bundle +TARGET = tst_external_IODevice +DESTDIR = ./ +QT += testlib remoteobjects +QT -= gui + +REPC_REPLICA = $$PWD/../pingpong.rep +RESOURCES += $$PWD/../cert/cert.qrc + +SOURCES += \ + tst_client.cpp |