Fix certificate checker callback lifetime.
OpenSSL's SSL_CTX_set_verify() function allows us to set a callback
called after certificate validation but doesn't provide a way to pass
private data to this callback. CL:183832 was passing the pointer to the
CertificateChecker instance using a global pointer, nevertheless the
lifetime of this pointer was wrong since libcurl can trigger this
callback asynchronously when the SSL certificates are downloaded.
This patch converts the CertificateChecker into a singleton class and
uses the same trick previously used to pass the ServerToCheck value
using different callbacks.
Bug: 25818567
Test: Run an update on edison-userdebug; FEATURES=test emerge-link update_engine
Change-Id: I84cdb2f8c5ac86d1463634e73e867f213f7a2f5a
diff --git a/metrics.cc b/metrics.cc
index 8f5536d..742ba7e 100644
--- a/metrics.cc
+++ b/metrics.cc
@@ -511,6 +511,8 @@
case ServerToCheck::kDownload:
metric = kMetricCertificateCheckDownload;
break;
+ case ServerToCheck::kNone:
+ return;
}
LOG(INFO) << "Uploading " << static_cast<int>(result) << " for metric "
<< metric;