Back out "[flipper] Wait for server when requesting certificate files"
Summary: This breaks in open source due to a missing rsocket symbol and blocks our legocastle task. Closes https://github.com/facebook/flipper/issues/224 Original commit changeset: e782b303b5e4 Reviewed By: jknoxville, danielbuechele Differential Revision: D9289450 fbshipit-source-id: b780c300394f5793e95ef2fb6b0e6ba0150caf9a
This commit is contained in:
committed by
Facebook Github Bot
parent
ef2659fd34
commit
229049b281
@@ -255,51 +255,20 @@ void SonarWebSocketImpl::requestSignedCertFromSonar() {
|
||||
|
||||
folly::dynamic message = folly::dynamic::object("method", "signCertificate")(
|
||||
"csr", csr.c_str())("destination", absoluteFilePath("").c_str());
|
||||
auto gettingCert = sonarState_->start("Getting cert from desktop");
|
||||
|
||||
sonarEventBase_->add([this, message, gettingCert]() {
|
||||
auto sendingCSR = sonarState_->start("Send CSR to desktop");
|
||||
sonarEventBase_->add([this, message, sendingCSR]() {
|
||||
client_->getRequester()
|
||||
->requestResponse(rsocket::Payload(folly::toJson(message)))
|
||||
->subscribe([this, gettingCert](rsocket::Payload p) {
|
||||
gettingCert->complete();
|
||||
SONAR_LOG("Certificate exchange complete.");
|
||||
->fireAndForget(rsocket::Payload(folly::toJson(message)))
|
||||
->subscribe([this, sendingCSR]() {
|
||||
sendingCSR->complete();
|
||||
// Disconnect after message sending is complete.
|
||||
// This will trigger a reconnect which should use the secure channel.
|
||||
// TODO: Connect immediately, without waiting for reconnect
|
||||
client_ = nullptr;
|
||||
},
|
||||
[this, message](folly::exception_wrapper e) {
|
||||
e.handle(
|
||||
[&](rsocket::ErrorWithPayload& errorWithPayload) {
|
||||
std::string errorMessage = errorWithPayload.payload.moveDataToString();
|
||||
|
||||
if (errorMessage.compare("not implemented")) {
|
||||
SONAR_LOG(("Desktop failed to provide certificates. Error from sonar desktop:\n" + errorMessage).c_str());
|
||||
} else {
|
||||
sendLegacyCertificateRequest(message);
|
||||
}
|
||||
},
|
||||
[e](...) {
|
||||
SONAR_LOG(("Error during certificate exchange:" + e.what()).c_str());
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
failedConnectionAttempts_ = 0;
|
||||
}
|
||||
|
||||
void SonarWebSocketImpl::sendLegacyCertificateRequest(folly::dynamic message) {
|
||||
// Desktop is using an old version of Flipper.
|
||||
// Fall back to fireAndForget, instead of requestResponse.
|
||||
auto sendingRequest = sonarState_->start("Sending fallback certificate request");
|
||||
client_->getRequester()
|
||||
->fireAndForget(rsocket::Payload(folly::toJson(message)))
|
||||
->subscribe([this, sendingRequest]() {
|
||||
sendingRequest->complete();
|
||||
client_ = nullptr;
|
||||
});
|
||||
}
|
||||
|
||||
std::string SonarWebSocketImpl::loadStringFromFile(std::string fileName) {
|
||||
if (!fileExists(fileName)) {
|
||||
return "";
|
||||
|
||||
Reference in New Issue
Block a user