This commit is contained in:
Albert Vaca 2016-03-08 07:29:34 -08:00
parent ff9775e1c9
commit 78d4ba2106
2 changed files with 9 additions and 11 deletions

View file

@ -213,9 +213,8 @@ void LanLinkProvider::connected()
// if ssl supported // if ssl supported
if (receivedPackage->get<int>("protocolVersion") >= NetworkPackage::ProtocolVersion) { if (receivedPackage->get<int>("protocolVersion") >= NetworkPackage::ProtocolVersion) {
// since I support ssl and remote device support ssl // since I support ssl and remote device support ssl
qCDebug(KDECONNECT_CORE) << "Setting up ssl server";
socket->setPeerVerifyName(receivedPackage->get<QString>("deviceId")); socket->setPeerVerifyName(deviceId);
QString certString = KdeConnectConfig::instance()->getDeviceProperty(deviceId, "certificate", QString()); QString certString = KdeConnectConfig::instance()->getDeviceProperty(deviceId, "certificate", QString());
if (!certString.isEmpty()) { if (!certString.isEmpty()) {
@ -229,7 +228,7 @@ void LanLinkProvider::connected()
socket->setPeerVerifyMode(QSslSocket::QueryPeer); socket->setPeerVerifyMode(QSslSocket::QueryPeer);
connect(socket, SIGNAL(sslErrors(QList<QSslError>)), this, SLOT(sslErrorsLogButIgnore(QList<QSslError>))); connect(socket, SIGNAL(sslErrors(QList<QSslError>)), this, SLOT(sslErrorsLogButIgnore(QList<QSslError>)));
} }
qCDebug(KDECONNECT_CORE) << "Starting server ssl"; qCDebug(KDECONNECT_CORE) << "Starting server ssl (I'm the client TCP socket)";
connect(socket, SIGNAL(encrypted()), this, SLOT(encrypted())); connect(socket, SIGNAL(encrypted()), this, SLOT(encrypted()));
socket->startServerEncryption(); socket->startServerEncryption();
@ -360,7 +359,6 @@ void LanLinkProvider::dataReceived()
if (NetworkPackage::ProtocolVersion <= np->get<int>("protocolVersion")) { if (NetworkPackage::ProtocolVersion <= np->get<int>("protocolVersion")) {
// since I support ssl and remote device support ssl // since I support ssl and remote device support ssl
qCDebug(KDECONNECT_CORE) << "Setting up ssl client";
bool isDeviceTrusted = KdeConnectConfig::instance()->trustedDevices().contains(deviceId); bool isDeviceTrusted = KdeConnectConfig::instance()->trustedDevices().contains(deviceId);
@ -378,7 +376,7 @@ void LanLinkProvider::dataReceived()
socket->setPeerVerifyMode(QSslSocket::QueryPeer); socket->setPeerVerifyMode(QSslSocket::QueryPeer);
connect(socket, SIGNAL(sslErrors(QList<QSslError>)), this, SLOT(sslErrorsLogButIgnore(QList<QSslError>))); connect(socket, SIGNAL(sslErrors(QList<QSslError>)), this, SLOT(sslErrorsLogButIgnore(QList<QSslError>)));
} }
qCDebug(KDECONNECT_CORE) << "Starting client ssl"; qCDebug(KDECONNECT_CORE) << "Starting client ssl (but I'm the server TCP socket)";
connect(socket, SIGNAL(encrypted()), this, SLOT(encrypted())); connect(socket, SIGNAL(encrypted()), this, SLOT(encrypted()));
socket->startClientEncryption(); socket->startClientEncryption();

View file

@ -118,21 +118,21 @@ KdeConnectConfig::KdeConnectConfig()
} else { } else {
// FIXME: We only use QCA here to generate the cert and key, would be nice to get rid of it completely.
// The same thing we are doing with QCA could be done invoking openssl (altought it's potentially less portable):
// openssl req -new -x509 -sha256 -newkey rsa:2048 -nodes -keyout privateKey.pem -days 3650 -out certificate.pem -subj "/O=KDE/OU=KDE Connect/CN=_e6e29ad4_2b31_4b6d_8f7a_9872dbaa9095_"
QCA::CertificateOptions certificateOptions = QCA::CertificateOptions(); QCA::CertificateOptions certificateOptions = QCA::CertificateOptions();
// FIXME : Set serial number for certificate. Time millis or any constant number?
QCA::BigInteger bigInteger(10);
QDateTime startTime = QDateTime::currentDateTime().addYears(-1); QDateTime startTime = QDateTime::currentDateTime().addYears(-1);
QDateTime endTime = startTime.addYears(10); QDateTime endTime = startTime.addYears(10);
QCA::CertificateInfo certificateInfo; QCA::CertificateInfo certificateInfo;
certificateInfo.insert(QCA::CommonName,deviceId()); certificateInfo.insert(QCA::CommonName,deviceId());
certificateInfo.insert(QCA::Organization,"KDE"); certificateInfo.insert(QCA::Organization,"KDE");
certificateInfo.insert(QCA::OrganizationalUnit,"Kde connect"); certificateInfo.insert(QCA::OrganizationalUnit,"Kde connect");
certificateOptions.setFormat(QCA::PKCS10);
certificateOptions.setSerialNumber(bigInteger);
certificateOptions.setInfo(certificateInfo); certificateOptions.setInfo(certificateInfo);
certificateOptions.setValidityPeriod(startTime, endTime);
certificateOptions.setFormat(QCA::PKCS10); certificateOptions.setFormat(QCA::PKCS10);
certificateOptions.setSerialNumber(QCA::BigInteger(10));
certificateOptions.setValidityPeriod(startTime, endTime);
d->certificate = QSslCertificate(QCA::Certificate(certificateOptions, d->privateKey).toPEM().toLatin1()); d->certificate = QSslCertificate(QCA::Certificate(certificateOptions, d->privateKey).toPEM().toLatin1());