diff options
author | Heikki Toivonen <heikki@heikkitoivonen.net> | 2005-06-01 21:50:59 +0000 |
---|---|---|
committer | Heikki Toivonen <heikki@heikkitoivonen.net> | 2005-06-01 21:50:59 +0000 |
commit | eecfd7a7924415fb7b642155362fac490d208bd5 (patch) | |
tree | a44649a10a33f3c3720375050a87bd9f1739268f /tests/test_x509.py | |
parent | 3694c1933d1cedf04ce7029d6e76568f8a6846e8 (diff) | |
download | m2crypto-eecfd7a7924415fb7b642155362fac490d208bd5.tar.gz |
Bug 3094, replace more raw pointers from interfaces with
M2Crypto wrapping objects.
Bug 3095, implement pkey_write_pem(), which makes
EVP.PKey.save_key_bio() work in all cases.
Bug 3120, using SSL verify callback function always crashes,
reviewed by Robin Dunn (from wxPython project).
Bug 3151, provide a new SSL verify callback function signature
that matches that of OpenSSL, and deprecate the old form (both
still work). Added more needed methods to X509_Store_Context.
git-svn-id: http://svn.osafoundation.org/m2crypto/trunk@282 2715db39-9adf-0310-9c64-84f055769b4b
Diffstat (limited to 'tests/test_x509.py')
-rw-r--r-- | tests/test_x509.py | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/tests/test_x509.py b/tests/test_x509.py index 53bae59..6fd143c 100644 --- a/tests/test_x509.py +++ b/tests/test_x509.py @@ -9,7 +9,7 @@ Copyright (C) 2004-2005 OSAF. All Rights Reserved. Author: Heikki Toivonen """ -RCS_id='$Id: test_x509.py,v 1.1 2003/05/11 16:17:25 ngps Exp $' +RCS_id = '$Id: test_x509.py,v 1.1 2003/05/11 16:17:25 ngps Exp $' import unittest import os, time @@ -20,14 +20,14 @@ class X509TestCase(unittest.TestCase): def callback(self, *args): pass - def mkreq(self, bits, serial, days): - pk=EVP.PKey() - x=X509.Request() - rsa=RSA.gen_key(bits,65537,self.callback) + def mkreq(self, bits): + pk = EVP.PKey() + x = X509.Request() + rsa = RSA.gen_key(bits, 65537, self.callback) pk.assign_rsa(rsa) - rsa=None # should not be freed here + rsa = None # should not be freed here x.set_pubkey(pk) - name=x.get_subject() + name = x.get_subject() name.C = "UK" name.CN = "OpenSSL Group" ext1 = X509.new_extension('subjectAltName', 'DNS:foobar.example.com') @@ -46,10 +46,13 @@ class X509TestCase(unittest.TestCase): assert(extstack[1].get_name() == 'nsComment') x.add_extensions(extstack) x.sign(pk,'md5') + assert x.verify(pk) + pk2 = x.get_pubkey() + assert x.verify(pk2) return x, pk def check_mkreq(self): - req, pk = self.mkreq(512, 0, 365) + (req, _) = self.mkreq(512) req.save_pem('tmp_request.pem') req2 = X509.load_request('tmp_request.pem') os.remove('tmp_request.pem') @@ -57,7 +60,7 @@ class X509TestCase(unittest.TestCase): assert req.as_text() == req2.as_text() def check_mkcert(self): - req, pk = self.mkreq(512, 0, 365) + req, pk = self.mkreq(512) pkey = req.get_pubkey() assert(req.verify(pkey)) sub = req.get_subject() @@ -78,8 +81,8 @@ class X509TestCase(unittest.TestCase): issuer.CN = 'The Issuer Monkey' issuer.O = 'The Organization Otherwise Known as My CA, Inc.' cert.set_issuer(issuer) - cert.set_pubkey(EVP.PKey(pkey)) - cert.set_pubkey(EVP.PKey(cert.get_pubkey())) + cert.set_pubkey(pkey) + cert.set_pubkey(cert.get_pubkey()) ext = X509.new_extension('subjectAltName', 'DNS:foobar.example.com') ext.set_critical(0) cert.add_ext(ext) @@ -88,6 +91,7 @@ class X509TestCase(unittest.TestCase): assert(cert.get_ext_at(0).get_name() == 'subjectAltName') assert(cert.get_ext_at(0).get_value() == 'DNS:foobar.example.com') assert cert.verify() + assert cert.verify(pkey) def suite(): return unittest.makeSuite(X509TestCase, 'check') |