(self)
| 4220 | self.assertIn((('commonName', name),), cert['subject']) |
| 4221 | |
| 4222 | def test_sni_callback(self): |
| 4223 | calls = [] |
| 4224 | server_context, other_context, client_context = self.sni_contexts() |
| 4225 | |
| 4226 | client_context.check_hostname = False |
| 4227 | |
| 4228 | def servername_cb(ssl_sock, server_name, initial_context): |
| 4229 | calls.append((server_name, initial_context)) |
| 4230 | if server_name is not None: |
| 4231 | ssl_sock.context = other_context |
| 4232 | server_context.set_servername_callback(servername_cb) |
| 4233 | |
| 4234 | stats = server_params_test(client_context, server_context, |
| 4235 | chatty=True, |
| 4236 | sni_name='supermessage') |
| 4237 | # The hostname was fetched properly, and the certificate was |
| 4238 | # changed for the connection. |
| 4239 | self.assertEqual(calls, [("supermessage", server_context)]) |
| 4240 | # CERTFILE4 was selected |
| 4241 | self.check_common_name(stats, 'fakehostname') |
| 4242 | |
| 4243 | calls = [] |
| 4244 | # The callback is called with server_name=None |
| 4245 | stats = server_params_test(client_context, server_context, |
| 4246 | chatty=True, |
| 4247 | sni_name=None) |
| 4248 | self.assertEqual(calls, [(None, server_context)]) |
| 4249 | self.check_common_name(stats, SIGNED_CERTFILE_HOSTNAME) |
| 4250 | |
| 4251 | # Check disabling the callback |
| 4252 | calls = [] |
| 4253 | server_context.set_servername_callback(None) |
| 4254 | |
| 4255 | stats = server_params_test(client_context, server_context, |
| 4256 | chatty=True, |
| 4257 | sni_name='notfunny') |
| 4258 | # Certificate didn't change |
| 4259 | self.check_common_name(stats, SIGNED_CERTFILE_HOSTNAME) |
| 4260 | self.assertEqual(calls, []) |
| 4261 | |
| 4262 | @unittest.expectedFailure # TODO: RUSTPYTHON; + TLSV1_ALERT_ACCESS_DENIED |
| 4263 | def test_sni_callback_alert(self): |
nothing calls this directly
no test coverage detected