Preliminary code commit to Secure OF-Agent to ONOS COmmunication
Added Error handling, few more follow-up fixes
PKI File Names Changed voltha.crt, voltha.key, voltha-CA.pem

Change-Id: I366342caf98bfe66e67a02838a68a3d799f774f3
diff --git a/ofagent/agent.py b/ofagent/agent.py
index 55c8bfb..626e105 100644
--- a/ofagent/agent.py
+++ b/ofagent/agent.py
@@ -19,6 +19,8 @@
 import structlog
 from twisted.internet import protocol
 from twisted.internet import reactor
+from twisted.internet import reactor, ssl
+from twisted.internet import reactor
 from twisted.internet.defer import Deferred, inlineCallbacks
 
 import loxi.of13 as of13
@@ -87,7 +89,19 @@
         while not self.exiting:
             host, port = self.resolve_endpoint(self.controller_endpoint)
             log.info('connecting', host=host, port=port)
-            self.connector = reactor.connectTCP(host, port, self)
+            try:
+               with open("/ofagent/pki/voltha.key") as keyFile:
+                    with open("/ofagent/pki/voltha.crt") as certFile:
+                         clientCert = ssl.PrivateCertificate.loadPEM(
+                              keyFile.read() + certFile.read())
+
+               ctx = clientCert.options()
+               self.connector = reactor.connectSSL(host, port, self, ctx)
+
+            except Exception as error:
+                log.error(event, reason=reason)
+
+
             self.d_disconnected = Deferred()
             yield self.d_disconnected
             log.debug('reconnect', after_delay=self.retry_interval)