forked from qt-creator/qt-creator
SSH: Support encrypted private keys in PKCS8 format.
Change-Id: I2fd10c1992442317b3ba7a7012f66a328930ef84 Reviewed-on: http://codereview.qt.nokia.com/2349 Reviewed-by: Christian Kandeler <christian.kandeler@nokia.com>
This commit is contained in:
@@ -36,6 +36,7 @@
|
||||
#include "sshcapabilities_p.h"
|
||||
#include "sshexception_p.h"
|
||||
#include "sshkeyexchange_p.h"
|
||||
#include "sshkeypasswordretriever_p.h"
|
||||
#include "sshpacket_p.h"
|
||||
|
||||
#include <botan/ber_dec.h>
|
||||
@@ -226,7 +227,7 @@ void SshEncryptionFacility::createAuthenticationKeyFromPKCS8(const QByteArray &p
|
||||
Pipe pipe;
|
||||
pipe.process_msg(convertByteArray(privKeyFileContents),
|
||||
privKeyFileContents.size());
|
||||
Private_Key * const key = PKCS8::load_key(pipe, m_rng);
|
||||
Private_Key * const key = PKCS8::load_key(pipe, m_rng, SshKeyPasswordRetriever());
|
||||
if (DSA_PrivateKey * const dsaKey = dynamic_cast<DSA_PrivateKey *>(key)) {
|
||||
m_authKeyAlgoName = SshCapabilities::PubKeyDss;
|
||||
m_authKey.reset(dsaKey);
|
||||
|
||||
54
src/libs/utils/ssh/sshkeypasswordretriever.cpp
Normal file
54
src/libs/utils/ssh/sshkeypasswordretriever.cpp
Normal file
@@ -0,0 +1,54 @@
|
||||
/**************************************************************************
|
||||
**
|
||||
** This file is part of Qt Creator
|
||||
**
|
||||
** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
||||
**
|
||||
** Contact: Nokia Corporation (info@qt.nokia.com)
|
||||
**
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
**
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this file.
|
||||
** Please review the following information to ensure the GNU Lesser General
|
||||
** Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** Other Usage
|
||||
**
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
** If you have questions regarding the use of this file, please contact
|
||||
** Nokia at info@qt.nokia.com.
|
||||
**
|
||||
**************************************************************************/
|
||||
#include "sshkeypasswordretriever_p.h"
|
||||
|
||||
#include <QtCore/QCoreApplication>
|
||||
#include <QtCore/QString>
|
||||
#include <QtGui/QInputDialog>
|
||||
|
||||
namespace Utils {
|
||||
namespace Internal {
|
||||
|
||||
std::string SshKeyPasswordRetriever::get_passphrase(const std::string &, const std::string &,
|
||||
UI_Result &result) const
|
||||
{
|
||||
bool ok;
|
||||
const QString &password = QInputDialog::getText(0,
|
||||
QCoreApplication::translate("Utils::Ssh", "Password required"),
|
||||
QCoreApplication::translate("Utils::Ssh", "Please enter the password for your private key."),
|
||||
QLineEdit::Password, QString(), &ok);
|
||||
result = ok ? OK : CANCEL_ACTION;
|
||||
return std::string(password.toLocal8Bit().data());
|
||||
}
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace Utils
|
||||
52
src/libs/utils/ssh/sshkeypasswordretriever_p.h
Normal file
52
src/libs/utils/ssh/sshkeypasswordretriever_p.h
Normal file
@@ -0,0 +1,52 @@
|
||||
/**************************************************************************
|
||||
**
|
||||
** This file is part of Qt Creator
|
||||
**
|
||||
** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
||||
**
|
||||
** Contact: Nokia Corporation (info@qt.nokia.com)
|
||||
**
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
**
|
||||
** This file may be used under the terms of the GNU Lesser General Public
|
||||
** License version 2.1 as published by the Free Software Foundation and
|
||||
** appearing in the file LICENSE.LGPL included in the packaging of this file.
|
||||
** Please review the following information to ensure the GNU Lesser General
|
||||
** Public License version 2.1 requirements will be met:
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** Other Usage
|
||||
**
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
** If you have questions regarding the use of this file, please contact
|
||||
** Nokia at info@qt.nokia.com.
|
||||
**
|
||||
**************************************************************************/
|
||||
#ifndef KEYPASSWORDRETRIEVER_H
|
||||
#define KEYPASSWORDRETRIEVER_H
|
||||
|
||||
#include <botan/ui.h>
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace Utils {
|
||||
namespace Internal {
|
||||
|
||||
class SshKeyPasswordRetriever : public Botan::User_Interface
|
||||
{
|
||||
public:
|
||||
std::string get_passphrase(const std::string &what, const std::string &source,
|
||||
UI_Result &result) const;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace Utils
|
||||
|
||||
#endif // KEYPASSWORDRETRIEVER_H
|
||||
@@ -86,6 +86,7 @@ SOURCES += $$PWD/environment.cpp \
|
||||
$$PWD/ssh/sftpchannel.cpp \
|
||||
$$PWD/ssh/sshremoteprocessrunner.cpp \
|
||||
$$PWD/ssh/sshconnectionmanager.cpp \
|
||||
$$PWD/ssh/sshkeypasswordretriever.cpp \
|
||||
$$PWD/outputformatter.cpp \
|
||||
$$PWD/flowlayout.cpp \
|
||||
$$PWD/networkaccessmanager.cpp
|
||||
@@ -187,6 +188,7 @@ HEADERS += \
|
||||
$$PWD/ssh/sshremoteprocessrunner.h \
|
||||
$$PWD/ssh/sshconnectionmanager.h \
|
||||
$$PWD/ssh/sshpseudoterminal.h \
|
||||
$$PWD/ssh/sshkeypasswordretriever_p.h \
|
||||
$$PWD/statuslabel.h \
|
||||
$$PWD/outputformatter.h \
|
||||
$$PWD/outputformat.h \
|
||||
|
||||
Reference in New Issue
Block a user