[ndnSIM] security: Avoid use of io_service::dispatch, use Scheduler instead

Scheduler is fully redirected to native NS-3 scheduler and is safe to use.
Use of `io_service` directly can have an undefined behavior within ndnSIM.

Change-Id: I379e7033b772d3b43a80549110a57950124aafc1
diff --git a/src/security/certificate-cache-ttl.cpp b/src/security/certificate-cache-ttl.cpp
index c1ad631..53b6da3 100644
--- a/src/security/certificate-cache-ttl.cpp
+++ b/src/security/certificate-cache-ttl.cpp
@@ -29,8 +29,7 @@
 CertificateCacheTtl::CertificateCacheTtl(boost::asio::io_service& io,
                                          const time::seconds& defaultTtl/* = time::seconds(3600)*/)
   : m_defaultTtl(defaultTtl)
-  , m_io(io)
-  , m_scheduler(m_io)
+  , m_scheduler(io)
 {
 }
 
@@ -41,7 +40,7 @@
 void
 CertificateCacheTtl::insertCertificate(shared_ptr<const v1::IdentityCertificate> certificate)
 {
-  m_io.dispatch([this, certificate] { this->insert(certificate); });
+  m_scheduler.scheduleEvent(time::seconds(0), [this, certificate] { this->insert(certificate); });
 }
 
 shared_ptr<const v1::IdentityCertificate>
@@ -57,7 +56,7 @@
 void
 CertificateCacheTtl::reset()
 {
-  m_io.dispatch([this] { this->removeAll(); });
+  m_scheduler.scheduleEvent(time::seconds(0), [this] { this->removeAll(); });
 }
 
 size_t
diff --git a/src/security/certificate-cache-ttl.hpp b/src/security/certificate-cache-ttl.hpp
index e0ef837..4c732ef 100644
--- a/src/security/certificate-cache-ttl.hpp
+++ b/src/security/certificate-cache-ttl.hpp
@@ -74,7 +74,6 @@
 
   time::seconds m_defaultTtl;
   Cache m_cache;
-  boost::asio::io_service& m_io;
   Scheduler m_scheduler;
 };