From 41f8674c3e43ffef4293f73e9b77280c2c6cc113 Mon Sep 17 00:00:00 2001 From: David Kaspar Date: Tue, 6 Aug 2013 11:35:45 +0200 Subject: [PATCH] Qnx: Fixing incorrect ssh key generation blackberry-connect tool requires to have public key with no comment or comment with 'usename@hostname' format QSsh::SshKeyGenerator creates comments in 'QtCreator/TIMEZONE' format there we are stripping them out This issue has been introduced by commit: bd064d50e625bb7e9efa0346ed899897f40bb678 Task-number: QTCREATORBUG-9888 Change-Id: Ied96720b004cfe4f5bb95adec3401b6b6d30db5c Reviewed-by: Tobias Hunger --- ...lackberrydeviceconfigurationwizardpages.cpp | 5 ----- src/plugins/qnx/blackberrysshkeysgenerator.cpp | 18 +++++++++++++++--- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/src/plugins/qnx/blackberrydeviceconfigurationwizardpages.cpp b/src/plugins/qnx/blackberrydeviceconfigurationwizardpages.cpp index 6d7eeec3a44..cf2220012fc 100644 --- a/src/plugins/qnx/blackberrydeviceconfigurationwizardpages.cpp +++ b/src/plugins/qnx/blackberrydeviceconfigurationwizardpages.cpp @@ -249,11 +249,6 @@ bool BlackBerryDeviceConfigurationWizardSshKeyPage::saveKeys(const QByteArray &p Utils::FileSaver pubSaver(publicKeyPath); - // blackberry-connect requires an @ character to be included in the RSA comment - const QString atHost = QLatin1Char('@') + QHostInfo::localHostName(); - QByteArray pubKeyContent = publicKey; - pubKeyContent.append(atHost.toLocal8Bit()); - pubSaver.write(publicKey); if (!pubSaver.finalize(this)) return false; diff --git a/src/plugins/qnx/blackberrysshkeysgenerator.cpp b/src/plugins/qnx/blackberrysshkeysgenerator.cpp index 3be7a6eea52..d9b10c0b0f5 100644 --- a/src/plugins/qnx/blackberrysshkeysgenerator.cpp +++ b/src/plugins/qnx/blackberrysshkeysgenerator.cpp @@ -53,8 +53,20 @@ void BlackBerrySshKeysGenerator::run() const bool success = m_keyGen->generateKeys(QSsh::SshKeyGenerator::Rsa, QSsh::SshKeyGenerator::Mixed, 4096, QSsh::SshKeyGenerator::DoNotOfferEncryption); - if (success) - emit sshKeysGenerationFinished(m_privateKeyPath, m_keyGen->privateKey(), m_keyGen->publicKey()); - else + if (success) { + // BB10 devices allow to use public key with no comment + // or a comment in username@hostname format + // QSsh::SshKeyGenerator class creates comments in 'QtCreator/TIMEZONE' format + // therefore stripping this comment out + QByteArray publicKey = m_keyGen->publicKey(); + int firstSpace = publicKey.indexOf(' '); + if (firstSpace >= 0) { + int secondSpace = publicKey.indexOf(' ', firstSpace + 1); + if (secondSpace >= 0) + publicKey.truncate(secondSpace); + } + + emit sshKeysGenerationFinished(m_privateKeyPath, m_keyGen->privateKey(), publicKey); + } else emit sshKeysGenerationFailed(m_keyGen->error()); }