diff --git a/domain-server/src/DomainServer.cpp b/domain-server/src/DomainServer.cpp index 2d7f5ca0cd..0f8301c96b 100644 --- a/domain-server/src/DomainServer.cpp +++ b/domain-server/src/DomainServer.cpp @@ -489,6 +489,10 @@ void DomainServer::setupICEHeartbeatForFullNetworking() { limitedNodeList->startSTUNPublicSocketUpdate(); // to send ICE heartbeats we'd better have a private key locally with an uploaded public key + auto& accountManager = AccountManager::getInstance(); + if (!accountManager.getAccountInfo().hasPrivateKey()) { + accountManager.generateNewDomainKeypair(limitedNodeList->getSessionUUID()); + } if (!_iceHeartbeatTimer) { // setup a timer to heartbeat with the ice-server every so often diff --git a/libraries/networking/src/AccountManager.cpp b/libraries/networking/src/AccountManager.cpp index 0d0ef1c93c..e9b44b2f87 100644 --- a/libraries/networking/src/AccountManager.cpp +++ b/libraries/networking/src/AccountManager.cpp @@ -589,7 +589,7 @@ void AccountManager::requestProfileError(QNetworkReply::NetworkError error) { void AccountManager::generateNewKeypair(bool isUserKeypair, const QUuid& domainID) { if (!isUserKeypair && domainID.isNull()) { - qWarning() << "AccountManager::generateNewKeypair called for domain keypair with no domain ID. Will not generate keypair."; + qCWarning(networking) << "AccountManager::generateNewKeypair called for domain keypair with no domain ID. Will not generate keypair."; return; } @@ -633,7 +633,15 @@ void AccountManager::processGeneratedKeypair() { persistAccountToSettings(); // upload the public key so data-web has an up-to-date key - const QString PUBLIC_KEY_UPDATE_PATH = "api/v1/user/public_key"; + const QString USER_PUBLIC_KEY_UPDATE_PATH = "api/v1/user/public_key"; + const QString DOMAIN_PUBLIC_KEY_UPDATE_PATH = "api/v1/domains/%1/public_key"; + + QString uploadPath; + if (keypairGenerator->getDomainID().isNull()) { + uploadPath = USER_PUBLIC_KEY_UPDATE_PATH; + } else { + uploadPath = DOMAIN_PUBLIC_KEY_UPDATE_PATH.arg(uuidStringWithoutCurlyBraces(keypairGenerator->getDomainID())); + } // setup a multipart upload to send up the public key QHttpMultiPart* requestMultiPart = new QHttpMultiPart(QHttpMultiPart::FormDataType); @@ -646,7 +654,7 @@ void AccountManager::processGeneratedKeypair() { requestMultiPart->append(keyPart); - sendRequest(PUBLIC_KEY_UPDATE_PATH, AccountManagerAuth::Required, QNetworkAccessManager::PutOperation, + sendRequest(uploadPath, AccountManagerAuth::Required, QNetworkAccessManager::PutOperation, JSONCallbackParameters(), QByteArray(), requestMultiPart); keypairGenerator->deleteLater();