MCPcopy Create free account
hub / github.com/Serial-Studio/Serial-Studio / activateFromFile

Method activateFromFile

app/src/Licensing/OfflineLicense.cpp:206–227  ·  view source on GitHub ↗

* @brief Imports and activates a certificate from a local file or file URL. */

Source from the content-addressed store, hash-verified

204 * @brief Imports and activates a certificate from a local file or file URL.
205 */
206bool Licensing::OfflineLicense::activateFromFile(const QString& path)
207{
208 const QString local = path.startsWith(QStringLiteral("file:")) ? QUrl(path).toLocalFile() : path;
209
210 QFile file(local);
211 if (!file.open(QIODevice::ReadOnly)) {
212 m_lastError = tr("Could not open the certificate file.");
213 showOfflineError(m_lastError, QMessageBox::Critical);
214 return false;
215 }
216
217 constexpr qint64 kMaxCertBytes = 64 * 1024;
218 if (file.size() > kMaxCertBytes) {
219 m_lastError = tr("The certificate file is too large to be valid.");
220 showOfflineError(m_lastError, QMessageBox::Critical);
221 return false;
222 }
223
224 const QByteArray framed = file.readAll();
225 file.close();
226 return applyCertificate(framed, true);
227}
228
229/**
230 * @brief Writes this device's fingerprint and app info to a .ssmachine file for the portal.

Callers 1

activateOfflineMethod · 0.80

Calls 5

showOfflineErrorFunction · 0.85
QUrlClass · 0.50
openMethod · 0.45
sizeMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected