Commit 41f8674c authored by David Kaspar's avatar David Kaspar
Browse files

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:
bd064d50



Task-number: QTCREATORBUG-9888

Change-Id: Ied96720b004cfe4f5bb95adec3401b6b6d30db5c
Reviewed-by: default avatarTobias Hunger <tobias.hunger@digia.com>
parent c83cf66d
......@@ -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;
......
......@@ -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());
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment