diff options
author | Jannis Voelker <jannis.voelker@basyskom.com> | 2020-09-09 12:37:39 +0200 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2020-09-09 13:45:50 +0000 |
commit | 46a3565a86122c0f87edf703c53894a49ac095dc (patch) | |
tree | e05cc0e1416f64d936b3b987a2f53dc275d7a1f5 | |
parent | a51f875b9513765502ff508c6dc58ceffc11b335 (diff) |
Fix file loading in the open62541 plugin
mbedTLS expects null terminated input for PEM encoded input data.
The previous code produced this as a side effect by not setting
the data length correctly after removing the newline character.
Change-Id: I503b55e58b4021e0881d447811ae2b5b6b3cca8e
Reviewed-by: Frank Meerkoetter <frank.meerkoetter@basyskom.com>
(cherry picked from commit 8cd6ecce523634abe108ac371638df288fe638eb)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r-- | src/plugins/opcua/open62541/qopen62541backend.cpp | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/plugins/opcua/open62541/qopen62541backend.cpp b/src/plugins/opcua/open62541/qopen62541backend.cpp index bbbc9af..42d9f48 100644 --- a/src/plugins/opcua/open62541/qopen62541backend.cpp +++ b/src/plugins/opcua/open62541/qopen62541backend.cpp @@ -1149,8 +1149,9 @@ bool Open62541AsyncBackend::loadFileToByteString(const QString &location, UA_Byt temp.data = nullptr; else { if (data.startsWith('-')) { // PEM file - // Remove trailing newline, mbedTLS doesn't tolerate this when loading a certificate - data = QString::fromLatin1(data).trimmed().toLatin1(); + // mbedTLS expects PEM encoded data to be null terminated + data = data.append('\0'); + temp.length = data.length(); } temp.data = reinterpret_cast<unsigned char *>(data.data()); } |