Add function to import a cert from a file
[cascardo/ipsilon.git] / ipsilon / tools / certs.py
old mode 100755 (executable)
new mode 100644 (file)
index 3a60488..ee07c74
@@ -1,5 +1,3 @@
-#!/usr/bin/python
-#
 # Copyright (C) 2014  Simo Sorce <simo@redhat.com>
 #
 # see file 'COPYING' for use and warranty information
@@ -44,13 +42,17 @@ class Certificate(object):
         proc = Popen(command)
         proc.wait()
 
+    def import_cert(self, certfile, keyfile):
+        self.cert = certfile
+        self.key = keyfile
+
     def get_cert(self):
         if not self.cert:
             raise ValueError('Certificate unavailable')
         with open(self.cert, 'r') as f:
             cert = f.readlines()
 
-        #poor man stripping of BEGIN/END lines
+        # poor man stripping of BEGIN/END lines
         if cert[0] == '-----BEGIN CERTIFICATE-----\n':
             cert = cert[1:]
         if cert[-1] == '-----END CERTIFICATE-----\n':