Patched ssl-Module with SSL_BUILD_*- and ERR_*- constants and added aliases for wrap_server() and wrap_client()
* dtls/__init__.py: Added DtlsSocket() from wrapper and aliases for wrap_server() and wrap_client() * dtls/err.py: Added patch_ssl_errors() to patch ssl-Module with ERR_* constants * dtls/patch.py: Patched ssl-Module with SSL_BUILD_* constants and added call to patch_ssl_errors() * dtls/wrapper.py: - Added a server and client function to alias/wrap DtlsSocket() creation - Cleanup of DtlsSocket.__init__() - Cleanup of exception handling in all member methods - Cleanup sendto() from client: no endless loop and first do a connect if not already connected * dtls/test/unit_wrapper.py: Adopt the changes made described above
This commit is contained in:
1 parent
d12b23ba9f
commit
dade3b8213
6 files changed
+166
-133
No files matched your search
@@ -15,8 +15,7 @@ from logging import basicConfig, DEBUG, getLogger
|
||||
_logger = getLogger(__name__)
|
||||
|
||||
import ssl
|
||||
from dtls import do_patch, error_codes
|
||||
from dtls.wrapper import DtlsSocket, SSL_BUILD_CHAIN_FLAG_NONE, SSL_BUILD_CHAIN_FLAG_NO_ROOT
|
||||
from dtls import DtlsSocket
|
||||
|
||||
|
||||
HOST = "localhost"
|
||||
@@ -186,7 +185,7 @@ tests = [
|
||||
'client_sigalgs': None},
|
||||
'result':
|
||||
{'ret_success': False,
|
||||
'error_code': error_codes.ERR_WRONG_SSL_VERSION,
|
||||
'error_code': ssl.ERR_WRONG_SSL_VERSION,
|
||||
'exception': None}},
|
||||
{'testcase':
|
||||
{'name': 'certificate verify fails',
|
||||
@@ -209,7 +208,7 @@ tests = [
|
||||
'client_sigalgs': None},
|
||||
'result':
|
||||
{'ret_success': False,
|
||||
'error_code': error_codes.ERR_CERTIFICATE_VERIFY_FAILED,
|
||||
'error_code': ssl.ERR_CERTIFICATE_VERIFY_FAILED,
|
||||
'exception': None}},
|
||||
{'testcase':
|
||||
{'name': 'no matching curve',
|
||||
@@ -232,7 +231,7 @@ tests = [
|
||||
'client_sigalgs': None},
|
||||
'result':
|
||||
{'ret_success': False,
|
||||
'error_code': error_codes.ERR_SSL_HANDSHAKE_FAILURE,
|
||||
'error_code': ssl.ERR_SSL_HANDSHAKE_FAILURE,
|
||||
'exception': None}},
|
||||
{'testcase':
|
||||
{'name': 'matching curve',
|
||||
@@ -278,7 +277,7 @@ tests = [
|
||||
'client_sigalgs': None},
|
||||
'result':
|
||||
{'ret_success': False,
|
||||
'error_code': error_codes.ERR_PORT_UNREACHABLE,
|
||||
'error_code': ssl.ERR_PORT_UNREACHABLE,
|
||||
'exception': None}},
|
||||
{'testcase':
|
||||
{'name': 'no matching sigalgs',
|
||||
@@ -301,7 +300,7 @@ tests = [
|
||||
'client_sigalgs': "RSA+SHA256"},
|
||||
'result':
|
||||
{'ret_success': False,
|
||||
'error_code': error_codes.ERR_SSL_HANDSHAKE_FAILURE,
|
||||
'error_code': ssl.ERR_SSL_HANDSHAKE_FAILURE,
|
||||
'exception': None}},
|
||||
{'testcase':
|
||||
{'name': 'matching sigalgs',
|
||||
@@ -347,7 +346,7 @@ tests = [
|
||||
'client_sigalgs': None},
|
||||
'result':
|
||||
{'ret_success': False,
|
||||
'error_code': error_codes.ERR_SSL_HANDSHAKE_FAILURE,
|
||||
'error_code': ssl.ERR_SSL_HANDSHAKE_FAILURE,
|
||||
'exception': None}},
|
||||
{'testcase':
|
||||
{'name': 'matching cipher',
|
||||
@@ -493,13 +492,8 @@ class TestSequenceMeta(type):
|
||||
class WrapperTests(unittest.TestCase):
|
||||
__metaclass__ = TestSequenceMeta
|
||||
|
||||
def setUp(self):
|
||||
super(WrapperTests, self).setUp()
|
||||
|
||||
do_patch()
|
||||
|
||||
def test_build_cert_chain(self):
|
||||
steps = [SSL_BUILD_CHAIN_FLAG_NONE, SSL_BUILD_CHAIN_FLAG_NO_ROOT]
|
||||
steps = [ssl.SSL_BUILD_CHAIN_FLAG_NONE, ssl.SSL_BUILD_CHAIN_FLAG_NO_ROOT]
|
||||
chatty, connectionchatty = CHATTY, CHATTY_CLIENT
|
||||
indata = 'FOO'
|
||||
certs = dict()
|
||||
|
||||
Reference in new issue
Block a user