with self.assertRaises(ValueError):
ctx.wrap_bio(ssl.MemoryBIO(), ssl.MemoryBIO(),
server_hostname=".example.org")
+ with self.assertRaises(TypeError):
+ ctx.wrap_bio(ssl.MemoryBIO(), ssl.MemoryBIO(),
+ server_hostname="example.org\x00evil.com")
class MemoryBIOTests(unittest.TestCase):
if (self->ctx->check_hostname) {
X509_VERIFY_PARAM *param = SSL_get0_param(self->ssl);
if (ip == NULL) {
- if (!X509_VERIFY_PARAM_set1_host(param, server_hostname, 0)) {
+ if (!X509_VERIFY_PARAM_set1_host(param, server_hostname,
+ strlen(server_hostname))) {
_setSSLError(NULL, 0, __FILE__, __LINE__);
goto error;
}
PyObject *res;
/* server_hostname is either None (or absent), or to be encoded
- as IDN A-label (ASCII str). */
+ as IDN A-label (ASCII str) without NULL bytes. */
if (hostname_obj != Py_None) {
if (!PyArg_Parse(hostname_obj, "es", "ascii", &hostname))
return NULL;
PyObject *res;
/* server_hostname is either None (or absent), or to be encoded
- as IDN A-label (ASCII str). */
+ as IDN A-label (ASCII str) without NULL bytes. */
if (hostname_obj != Py_None) {
if (!PyArg_Parse(hostname_obj, "es", "ascii", &hostname))
return NULL;