Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SSL client validation (certificate-based authentication) #295

Closed
wants to merge 6 commits into from
34 changes: 30 additions & 4 deletions tests/test_websockifyserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,10 +257,36 @@ def fake_select(rlist, wlist, xlist, timeout=None):
sock, '127.0.0.1')

def test_do_handshake_ssl_error_eof_raises_close_error(self):
# TODO: re-implement this test.
# Test was incompatible with new style socket wrapping offered by
# ssl.create_default_context.
pass
server = self._get_server(daemon=True, ssl_only=0, idle_timeout=1)

sock = FakeSocket("\x16some ssl data")

def fake_select(rlist, wlist, xlist, timeout=None):
return ([sock], [], [])

def fake_wrap_socket(*args, **kwargs):
raise ssl.SSLError(ssl.SSL_ERROR_EOF)

class fake_create_default_context():
def __init__(self, purpose):
self.verify_mode = None
def load_cert_chain(self, certfile, keyfile):
pass
def set_default_verify_paths(self):
pass
def load_verify_locations(self, cafile):
pass
def wrap_socket(self, *args, **kwargs):
raise ssl.SSLError(ssl.SSL_ERROR_EOF)

self.stubs.Set(select, 'select', fake_select)
# for recent versions of python
self.stubs.Set(ssl, 'create_default_context', fake_create_default_context)
# for fallback for old versions of python
self.stubs.Set(ssl, 'wrap_socket', fake_wrap_socket)
self.assertRaises(
websockifyserver.WebSockifyServer.EClose, server.do_handshake,
sock, '127.0.0.1')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Merge this in to the first commit as well.


def test_fallback_sigchld_handler(self):
# TODO(directxman12): implement this
Expand Down