QOpcUaGdsClient Class

Handles communication with the GDS Server. More...

Header: #include <QOpcUaGdsClient>
CMake: find_package(Qt6 REQUIRED COMPONENTS OpcUa)
target_link_libraries(mytarget PRIVATE Qt6::OpcUa)
qmake: QT += opcua
Inherits: QObject

Public Types

enum class Error { NoError, InvalidBackend, InvalidEndpoint, ConnectionError, DirectoryNodeNotFound, …, FailedToGetCertificate }
enum class State { Idle, BackendInstantiated, Connecting, Connected, RegisteringApplication, …, Error }

Public Functions

QOpcUaGdsClient(QObject *parent = nullptr)
virtual ~QOpcUaGdsClient()
QString applicationId() const
const QOpcUaApplicationIdentity &applicationIdentity() const
const QOpcUaApplicationRecordDataType &applicationRecord() const
const QString &backend() const
int certificateCheckInterval() const
const QOpcUaX509DistinguishedName &distinguishedNameCertificateSigningRequestPreset() const
const QString &dnsCertificateSigningRequestPreset() const
const QOpcUaEndpointDescription &endpoint() const
QOpcUaGdsClient::Error error() const
const QOpcUaPkiConfiguration &pkiConfiguration() const
void setApplicationIdentity(const QOpcUaApplicationIdentity &appIdentity)
void setApplicationRecord(const QOpcUaApplicationRecordDataType &appRecord)
void setBackend(const QString &backend)
void setCertificateCheckInterval(int interval)
void setCertificateSigningRequestPresets(const QOpcUaX509DistinguishedName &dn, const QString &dns)
void setEndpoint(const QOpcUaEndpointDescription &endpoint)
void setPkiConfiguration(const QOpcUaPkiConfiguration &pkiConfig)
void setTrustListUpdateInterval(int interval)
void start()
QOpcUaGdsClient::State state() const
int trustListUpdateInterval() const
void unregisterApplication()

Signals

void applicationRegistered()
void authenticationRequired(QOpcUaAuthenticationInformation &authInfo)
void certificateGroupsReceived(QStringList certificateGroups)
void certificateUpdateRequired()
void certificateUpdated()
void errorChanged(QOpcUaGdsClient::Error error)
void stateChanged(QOpcUaGdsClient::State state)
void trustListUpdated()
void unregistered()

Detailed Description

This class is currently available as a Technology Preview, and therefore the API and functionality provided by the class may be subject to change at any time without prior notice.

This class handles all steps needed for communication with a GDS server. Provided with information about the application it does registering with the server and managing key/certificates.

Only few details need to be known in order to take part in a secured network.

First time registration requires administrative privileges using username and password for authentication. All further authentications are application based, using the certificate which was received first.

Expecting the whole process to succeed, you have to wait for the applicationRegistered signal.

Most of the setup structs have to be the same as for the connection with QOpcUaClient afterwards and can be shared.

Setting up a GDS client:

 QOpcUaGdsClient c;

 // In case the credentials are needed
 QObject::connect(&c, &QOpcUaGdsClient::authenticationRequired, [&](QOpcUaAuthenticationInformation &authInfo) {
         authInfo.setUsernameAuthentication("root", "secret");
  });

 // Await success
 QObject::connect(&c, &QOpcUaGdsClient::applicationRegistered, [&]() {
     qDebug() << "Application" << c.applicationId() << "registered";
 });

 c.setBackend(...);
 c.setEndpoint(...);
 c.setApplicationIdentity(...);
 c.setPkiConfiguration(...);
 c.setApplicationRecord(...);
 c.setCertificateSigningRequestPresets(...);
 c.start();

Member Type Documentation

enum class QOpcUaGdsClient::Error

This enum is used to specify errors, that could happen during the registration process.

ConstantValueDescription
QOpcUaGdsClient::Error::NoError0Everying is fine
QOpcUaGdsClient::Error::InvalidBackend1The backend could not be instantiated. The backend string given, does not match any backend or loading the plugin failed.
QOpcUaGdsClient::Error::InvalidEndpoint2The given endpoint is not valid.
QOpcUaGdsClient::Error::ConnectionError3The connection to the server endpoint failed.
QOpcUaGdsClient::Error::DirectoryNodeNotFound4The directory node on the server could not be resolved
QOpcUaGdsClient::Error::FailedToRegisterApplication5The registration of the application was not successful.
QOpcUaGdsClient::Error::FailedToUnregisterApplication6The unregistration of the application was not successful.
QOpcUaGdsClient::Error::FailedToGetCertificateStatus7The status of the current certificate could not be retrieved.
QOpcUaGdsClient::Error::FailedToGetCertificate8A certificate could not be retrieved from the server.

enum class QOpcUaGdsClient::State

This enum is used to specify the current state of the registration of the GDS client.

ConstantValueDescription
QOpcUaGdsClient::State::Idle0The client was not started yet.
QOpcUaGdsClient::State::BackendInstantiated1The backend was instantiated
QOpcUaGdsClient::State::Connecting2A connecting to the server is being made
QOpcUaGdsClient::State::Connected3The connection to the server endpoint was successful.
QOpcUaGdsClient::State::RegisteringApplication4The application is being registered with the server.
QOpcUaGdsClient::State::ApplicationRegistered5Registering the application with the server was successful.
QOpcUaGdsClient::State::Error6An error happened. See the return value of error() and the terminal output for more details.

Member Function Documentation

QOpcUaGdsClient::QOpcUaGdsClient(QObject *parent = nullptr)

Constructs a GDS client with parent as the parent object.

[virtual noexcept] QOpcUaGdsClient::~QOpcUaGdsClient()

Destructs a GDS client.

QString QOpcUaGdsClient::applicationId() const

Returns the application id assigned by the server.

Is is a shortcut to receive the application id from the application record data.

See also applicationRecord().

const QOpcUaApplicationIdentity &QOpcUaGdsClient::applicationIdentity() const

Returns the current applicationIdentity.

See also setApplicationIdentity().

const QOpcUaApplicationRecordDataType &QOpcUaGdsClient::applicationRecord() const

Returns the application record data that is used by the client.

See also setApplicationRecord().

[signal] void QOpcUaGdsClient::applicationRegistered()

This signal is emitted when an application was registered successfully.

[signal] void QOpcUaGdsClient::authenticationRequired(QOpcUaAuthenticationInformation &authInfo)

This signal is emitted when the GDS client tries to do a first time authentication with a server, that requires administrative privileges.

authInfo has to be filled with valid authentication information. This slot must not be used crossing thread boundaries.

const QString &QOpcUaGdsClient::backend() const

Returns the current backend setting.

If the backend was changed after starting the client, it will return the changed setting, but not the actually used instance.

See also setBackend().

int QOpcUaGdsClient::certificateCheckInterval() const

Returns the interval in milliseconds for checking the validity of the client certificate.

See also setCertificateCheckInterval().

[signal] void QOpcUaGdsClient::certificateGroupsReceived(QStringList certificateGroups)

This signal is emitted when the GDS client receives a new list of certificateGroups for this application.

[signal] void QOpcUaGdsClient::certificateUpdateRequired()

This signal is emitted when the GDS client detects that an update of the currently used certificate is necessary.

This could be caused by the server, requesting the client to update the certificate, when the certificate's due date is met or if the certificate is self-signed.

The certificate update is handled automatically. This signal is only for informational purpose that an update is going to happen.

[signal] void QOpcUaGdsClient::certificateUpdated()

This signal is emitted when the GDS client received a new certificate that was stored on disk.

const QOpcUaX509DistinguishedName &QOpcUaGdsClient::distinguishedNameCertificateSigningRequestPreset() const

Returns the distinguished name preset for certificate siging requests.

const QString &QOpcUaGdsClient::dnsCertificateSigningRequestPreset() const

Returns the DNS preset for certificate siging requests.

const QOpcUaEndpointDescription &QOpcUaGdsClient::endpoint() const

Returns the current endpoint setting.

If the endpoint was changed after starting the client, it will return the changed setting, but not the actually used endpoint.

See also setEndpoint().

QOpcUaGdsClient::Error QOpcUaGdsClient::error() const

Returns the current error state.

[signal] void QOpcUaGdsClient::errorChanged(QOpcUaGdsClient::Error error)

This signal is emitted when an error occurred.

const QOpcUaPkiConfiguration &QOpcUaGdsClient::pkiConfiguration() const

Returns the current pkiConfiguration.

See also setPkiConfiguration().

void QOpcUaGdsClient::setApplicationIdentity(const QOpcUaApplicationIdentity &appIdentity)

Sets the application identity appIdentity to be used by the client.

This identity is used to register with the GDS server. This function has to be called before starting the GDS client. Changing this setting afterwards has no effect.

See also applicationIdentity().

void QOpcUaGdsClient::setApplicationRecord(const QOpcUaApplicationRecordDataType &appRecord)

Sets the application record data appRecord to be used by the client.

This data is used to register with the GDS server. This function has to be called before starting the GDS client.

Most of the data is the same as in the application identity. After registration the assigned application id can be retrieved.

See also applicationRecord() and setApplicationIdentity.

void QOpcUaGdsClient::setBackend(const QString &backend)

Sets the backend to be used by the client to communicate with the server to backend.

This function has to be called before starting the GDS client. Changing this setting afterwards has no effect.

See also backend(), QOpcUaProvider::availableBackends(), and start().

void QOpcUaGdsClient::setCertificateCheckInterval(int interval)

Sets the interval in milliseconds for checking the validity of the client certificate to interval.

See also certificateCheckInterval().

void QOpcUaGdsClient::setCertificateSigningRequestPresets(const QOpcUaX509DistinguishedName &dn, const QString &dns)

Sets the presets for certificate siging requests; the distinguished name dn and the DNS string dns.

When creating a certificate signing request some additional information is needed, that is not provided by the application identity.

This function has to be called before starting the GDS client.

See also setApplicationIdentity().

void QOpcUaGdsClient::setEndpoint(const QOpcUaEndpointDescription &endpoint)

Sets the endpoint to be used by the client to communicate with the server to endpoint.

This function has to be called before starting the GDS client. Changing this setting afterwards has no effect.

Communication to a GDS server is only possible through an encrypted endpoint. Using an unencrypted endpoint will fail.

See also endpoint().

void QOpcUaGdsClient::setPkiConfiguration(const QOpcUaPkiConfiguration &pkiConfig)

Sets the PKI configuration pkiConfig to be used by the client.

All certificates, keys and trust lists will be used from or stored to the locations given. In order to use the certificate received from the GDS, the same configuration has to be used with QOpcUaClient.

This function has to be called before starting the GDS client. Changing this setting afterwards has no effect.

See also pkiConfiguration().

void QOpcUaGdsClient::setTrustListUpdateInterval(int interval)

Sets the interval in milliseconds for updating the trust list from the server to interval.

See also trustListUpdateInterval().

void QOpcUaGdsClient::start()

Starts the client process.

After setting up all information, the client can be started.

QOpcUaGdsClient::State QOpcUaGdsClient::state() const

Returns the current client state.

[signal] void QOpcUaGdsClient::stateChanged(QOpcUaGdsClient::State state)

This signal is emitted when the internal state of the client changes. The state indicates the new state.

int QOpcUaGdsClient::trustListUpdateInterval() const

Returns the interval in milliseconds for updating the trust list from the server.

See also setTrustListUpdateInterval().

[signal] void QOpcUaGdsClient::trustListUpdated()

This signal is emitted when the GDS client has received a new trust list from the server and stored to disk.

void QOpcUaGdsClient::unregisterApplication()

Unregisters an application from the server.

This function can be used when an application has to be removed permanently from the network. It does not need to be called when rebooting or shutting down.

[signal] void QOpcUaGdsClient::unregistered()

This signal is emitted when the GDS client has unregistered the application.