diff options
author | Cory Benfield <lukasaoz@gmail.com> | 2015-04-11 17:57:35 -0400 |
---|---|---|
committer | Cory Benfield <lukasaoz@gmail.com> | 2015-04-13 16:11:48 -0400 |
commit | e3d5715cfd22c886570b84704dc97b9e3c2e4dec (patch) | |
tree | aac3fdbe7e1c8d25fe489f87266c920cf2fd6999 | |
parent | e8e9c38ce7d8467608affe31ab10a5e6ce11575c (diff) | |
download | pyopenssl-e3d5715cfd22c886570b84704dc97b9e3c2e4dec.tar.gz |
Test for client-only ALPN.
-rw-r--r-- | OpenSSL/test/test_ssl.py | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/OpenSSL/test/test_ssl.py b/OpenSSL/test/test_ssl.py index 261b9a4..220698d 100644 --- a/OpenSSL/test/test_ssl.py +++ b/OpenSSL/test/test_ssl.py @@ -1898,6 +1898,41 @@ class ApplicationLayerProtoNegotiationTests(TestCase, _LoopbackMixin): self.assertEqual([(client, [b'http/1.1', b'spdy/2'])], select_args) + def test_alpn_no_server(self): + """ + Tests that when clients and servers cannot agree on what protocol to + use next because the server doesn't offer ALPN. + """ + select_args = [] + def select(conn, options): + select_args.append((conn, options)) + return b'' + + client_context = Context(TLSv1_METHOD) + client_context.set_alpn_protos([b'http/1.1', b'spdy/2']) + + server_context = Context(TLSv1_METHOD) + + # Necessary to actually accept the connection + server_context.use_privatekey( + load_privatekey(FILETYPE_PEM, server_key_pem)) + server_context.use_certificate( + load_certificate(FILETYPE_PEM, server_cert_pem)) + + # Do a little connection to trigger the logic + server = Connection(server_context, None) + server.set_accept_state() + + client = Connection(client_context, None) + client.set_connect_state() + + # Do the dance. + self._interactInMemory(server, client) + + self.assertEqual([(client, [b'http/1.1', b'spdy/2'])], select_args) + self.assertEqual(client.get_alpn_proto_negotiated(), b'') + + class SessionTests(TestCase): """ |