diff options
author | Rainer Keller <Rainer.Keller@qt.io> | 2019-07-23 10:30:21 +0200 |
---|---|---|
committer | Rainer Keller <Rainer.Keller@qt.io> | 2019-07-31 15:06:42 +0200 |
commit | b886f45d068764fffaf6a13fca6f8f86f0b22531 (patch) | |
tree | 32f7d3e43bdd67667c0bc8a31a9c6b7af0f1c4a7 | |
parent | f7155c1bdffbab5cd98579789a2fbcffe427a019 (diff) |
In case of a connection to a secure endpoint the PKI configuration
has to contain some mandatory settings.
Change-Id: Ib92348222fdb3fa2af8d7d4a701f2f4bb94baf7b
Reviewed-by: Jannis Völker <jannis.voelker@basyskom.com>
-rw-r--r-- | src/opcua/client/qopcuaclientprivate.cpp | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/opcua/client/qopcuaclientprivate.cpp b/src/opcua/client/qopcuaclientprivate.cpp index 1e4c0ae..dfec694 100644 --- a/src/opcua/client/qopcuaclientprivate.cpp +++ b/src/opcua/client/qopcuaclientprivate.cpp @@ -125,6 +125,23 @@ QOpcUaClientPrivate::~QOpcUaClientPrivate() void QOpcUaClientPrivate::connectToEndpoint(const QOpcUaEndpointDescription &endpoint) { + // Some pre-connection checks + if (QOpcUa::isSecurePolicy(endpoint.securityPolicy())) { + // We are going to connect to a secure endpoint + + if (!m_pkiConfig.isPkiValid()) { + qCWarning(QT_OPCUA) << "Can not connect to a secure endpoint without a valid PKI setup."; + setStateAndError(m_state, QOpcUaClient::AccessDenied); + return; + } + + if (!m_pkiConfig.isKeyAndCertificateFileSet()) { + qCWarning(QT_OPCUA) << "Can not connect to a secure endpoint without a client certificate."; + setStateAndError(m_state, QOpcUaClient::AccessDenied); + return; + } + } + m_endpoint = endpoint; m_impl->connectToEndpoint(endpoint); } |