source: TI12-security/trunk/NDGSecurity/python/Tests/pyopenssl/test_ssl.py @ 7572

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/TI12-security/trunk/NDGSecurity/python/Tests/pyopenssl/test_ssl.py@7572
Revision 7572, 811 bytes checked in by pjkersha, 10 years ago (diff)

2.0.0 release for NDG Security

  • made extra_requires entry in setup for ndg_xacml
Line 
1import unittest
2import socket
3from OpenSSL import SSL
4
5
6class SSLTestCase(unittest.TestCase):
7    def test01(self):
8        addr = ('localhost', 7443)
9        caDir = '/home/pjkersha/workspace/ndg_security_python/ndg_security_test/ndg/security/test/config/ca'
10       
11        ctx = SSL.Context(SSL.SSLv3_METHOD)
12        ctx.load_verify_locations(None, caDir)
13        ctx.set_verify_depth(9)
14        def _callback(conn, x509, errnum, errdepth, ok):
15            return ok
16       
17        ctx.set_verify(SSL.VERIFY_PEER, _callback)
18#        ctx.set_verify(SSL.VERIFY_NONE, _callback)
19        print "Verify mode = %d" % ctx.get_verify_mode()
20        conn = SSL.Connection(ctx, socket.socket())
21        conn.connect(addr)
22        conn.do_handshake()
23       
24       
25if __name__ == "__main__":
26    unittest.main()
Note: See TracBrowser for help on using the repository browser.