new file:   cert-request.proto
	modified:   end-device.py
diff --git a/cert-request.proto b/cert-request.proto
new file mode 100644
index 0000000..6c81dd6
--- /dev/null
+++ b/cert-request.proto
@@ -0,0 +1,11 @@
+message CertificateRequestMessage {
+	message Name {
+		repeated bytes components = 8;
+	}
+	message CertificateRequest {
+		required Name keyName = 220;
+        required uint32 keyType = 221;
+        required bytes keyBits = 222;
+	}
+	required CertificateRequest command = 223;
+}
diff --git a/end-device.py b/end-device.py
index 67fc150..cbcb841 100644
--- a/end-device.py
+++ b/end-device.py
@@ -21,6 +21,7 @@
 from pyndn import Name
 from pyndn import Face
 from base_node import BaseNode
+import CertificateRequestMessage
 
 def dump(*list):
     result = ""
@@ -48,6 +49,60 @@
         self._callbackCount += 1
         dump("Time out for interest", interest.getName().toUri())
 
+    def _sendCertificateRequest(self, keyIdentity):
+        """
+        We compose a command interest with our public key info so the controller
+        can sign us a certificate that can be used with other nodes in the network.
+        """
+
+        #TODO: GENERATE A NEW PUBLIC/PRIVATE PAIR INSTEAD OF COPYING
+        makeKey = False
+        try:
+            defaultKey = self._identityStorage.getDefaultKeyNameForIdentity(keyIdentity)
+            newKeyName = defaultKey
+        except SecurityException:
+            defaultIdentity = self._keyChain.getDefaultIdentity()
+            defaultKey = self._identityStorage.getDefaultKeyNameForIdentity(defaultIdentity)
+            newKeyName = self._identityStorage.getNewKeyName(keyIdentity, True)
+            makeKey = True
+             
+        self.log.debug("Found key: " + defaultKey.toUri()+ " renaming as: " + newKeyName.toUri())
+
+        keyType = self._identityStorage.getKeyType(defaultKey)
+        keyDer = self._identityStorage.getKey(defaultKey)
+
+        if makeKey:
+            try:
+                privateDer = self._identityManager.getPrivateKey(defaultKey)
+            except SecurityException:
+                # XXX: is recovery impossible?
+                pass
+            else:
+                try:
+                    self._identityStorage.addKey(newKeyName, keyType, keyDer)
+                    self._identityManager.addPrivateKey(newKeyName, privateDer)
+                except SecurityException:
+                    # TODO: key shouldn't exist...
+                    pass
+
+        message = CertificateRequestMessage()
+        message.command.keyType = keyType
+        message.command.keyBits = keyDer.toRawStr()
+
+        for component in range(newKeyName.size()):
+            message.command.keyName.components.append(newKeyName.get(component).toEscapedString())
+
+        paramComponent = ProtobufTlv.encode(message)
+
+        interestName = Name(self._policyManager.getTrustRootIdentity()).append("certificateRequest").append(paramComponent)
+        interest = Interest(interestName)
+        interest.setInterestLifetimeMilliseconds(10000) # takes a tick to verify and sign
+        self._hmacHandler.signInterest(interest, keyName=self.prefix)
+
+        self.log.info("Sending certificate request to controller")
+        self.log.debug("Certificate request: "+interest.getName().toUri())
+        self.face.expressInterest(interest, self._onCertificateReceived, self._onCertificateTimeout)
+
 if __name__ == '__main__':
     face = Face("")