DER encoding: implement PublicKey::toDer().
diff --git a/include/ndn-cpp/security/certificate/public-key.hpp b/include/ndn-cpp/security/certificate/public-key.hpp
index 0a48b5f..3b861b4 100644
--- a/include/ndn-cpp/security/certificate/public-key.hpp
+++ b/include/ndn-cpp/security/certificate/public-key.hpp
@@ -15,6 +15,8 @@
 
 namespace ndn {
 
+  namespace der { class DerNode; }
+
 class PublicKey {
 public:    
   /**
@@ -32,14 +34,12 @@
   {
   }
 
-#if 0
   /**
    * Encode the public key into DER.
    * @return the encoded DER syntax tree.
    */
-  Ptr<der::DerNode>
+  ptr_lib::shared_ptr<der::DerNode>
   toDer();
-#endif
 
   /**
    * Decode the public key from DER blob.
diff --git a/ndn-cpp/security/certificate/public-key.cpp b/ndn-cpp/security/certificate/public-key.cpp
index 183b6f2..1d5deb8 100644
--- a/ndn-cpp/security/certificate/public-key.cpp
+++ b/ndn-cpp/security/certificate/public-key.cpp
@@ -6,8 +6,12 @@
  * See COPYING for copyright and distribution information.
  */
 
+// We can use ndnboost::iostreams because this is internal and will not conflict with the application if it uses boost::iostreams.
+#include <ndnboost/iostreams/stream.hpp>
+#include <ndnboost/iostreams/device/array.hpp>
 #include <ndn-cpp/security//security-exception.hpp>
 #include "../../c/util/crypto.h"
+#include "../../encoding/der/der.hpp"
 #include <ndn-cpp/security/certificate/public-key.hpp>
 
 using namespace std;
@@ -15,16 +19,13 @@
 
 namespace ndn {
 
-#if 0
-Ptr<der::DerNode>
-PublicKey::toDER()
+shared_ptr<der::DerNode>
+PublicKey::toDer()
 {
-  boost::iostreams::stream
-    <boost::iostreams::array_source> is (m_key.buf (), key_.size ());
+  ndnboost::iostreams::stream<ndnboost::iostreams::array_source> is((const char*)keyDer_.buf (), keyDer_.size ());
 
-  return der::DerNode::parse(reinterpret_cast<InputIterator &> (is));
+  return der::DerNode::parse(reinterpret_cast<der::InputIterator&> (is));
 }
-#endif
 
 static int RSA_OID[] = { 1, 2, 840, 113549, 1, 1, 1 };