* @brief Imports and activates a certificate from a local file or file URL. */
| 204 | * @brief Imports and activates a certificate from a local file or file URL. |
| 205 | */ |
| 206 | bool 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. |
no test coverage detected