summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Behrens <cbehrens@codestud.com>2011-05-27 06:56:50 +0000
committerChris Behrens <cbehrens@codestud.com>2011-05-27 06:56:50 +0000
commita92f2bcbbaa40458e81bad3f6cb21288161322f9 (patch)
tree0944373b23dc501d7daa7ae19bf9d7ef758aa30c
parenta7c36f68793a7db454d344187d4596ebecc8ade0 (diff)
fix calls to openssl properly now. Only append \n to stdin when decoding. Updated the test slightly, also.
-rw-r--r--nova/tests/test_xenapi.py1
-rw-r--r--nova/virt/xenapi/vmops.py6
2 files changed, 6 insertions, 1 deletions
diff --git a/nova/tests/test_xenapi.py b/nova/tests/test_xenapi.py
index 18a267896..3ba37a762 100644
--- a/nova/tests/test_xenapi.py
+++ b/nova/tests/test_xenapi.py
@@ -595,6 +595,7 @@ class XenAPIDiffieHellmanTestCase(test.TestCase):
def test_encryption(self):
msg = "This is a top-secret message"
enc = self.alice.encrypt(msg)
+ self.assertFalse(enc.endswith('\n'))
dec = self.bob.decrypt(enc)
self.assertEquals(dec, msg)
diff --git a/nova/virt/xenapi/vmops.py b/nova/virt/xenapi/vmops.py
index 6d516ddbc..1d8678ce2 100644
--- a/nova/virt/xenapi/vmops.py
+++ b/nova/virt/xenapi/vmops.py
@@ -1195,12 +1195,16 @@ class SimpleDH(object):
'-nosalt %(dec_flag)s')
if which.lower()[0] == 'd':
dec_flag = ' -d'
+ # When decoding base64, we need to make sure there's a
+ # single '\n' at the end of the base64 encoded data.
+ # It's kinda dumb that openssl wants to see a newline
+ text = text.strip('\n') + '\n'
else:
dec_flag = ''
shared = self._shared
cmd = base_cmd % locals()
proc = _runproc(cmd)
- proc.stdin.write(text + '\n')
+ proc.stdin.write(text)
proc.stdin.close()
proc.wait()
err = proc.stderr.read()