[2.7] bpo-30622: Change NPN detection: (GH-2079) (#3316) · python/cpython@72ed233 (original) (raw)
`@@ -280,7 +280,7 @@ static unsigned int _ssl_locks_count = 0;
`
280
280
`typedef struct {
`
281
281
`PyObject_HEAD
`
282
282
`SSL_CTX *ctx;
`
283
``
`-
#ifdef OPENSSL_NPN_NEGOTIATED
`
``
283
`+
#if defined(OPENSSL_NPN_NEGOTIATED) && !defined(OPENSSL_NO_NEXTPROTONEG)
`
284
284
`unsigned char *npn_protocols;
`
285
285
`int npn_protocols_len;
`
286
286
`#endif
`
`@@ -1502,7 +1502,7 @@ static PyObject *PySSL_version(PySSLSocket *self)
`
1502
1502
`return PyUnicode_FromString(version);
`
1503
1503
`}
`
1504
1504
``
1505
``
`-
#ifdef OPENSSL_NPN_NEGOTIATED
`
``
1505
`+
#if defined(OPENSSL_NPN_NEGOTIATED) && !defined(OPENSSL_NO_NEXTPROTONEG)
`
1506
1506
`static PyObject *PySSL_selected_npn_protocol(PySSLSocket *self) {
`
1507
1507
`const unsigned char *out;
`
1508
1508
`unsigned int outlen;
`
`@@ -2140,7 +2140,7 @@ context_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
`
2140
2140
`return NULL;
`
2141
2141
` }
`
2142
2142
`self->ctx = ctx;
`
2143
``
`-
#ifdef OPENSSL_NPN_NEGOTIATED
`
``
2143
`+
#if defined(OPENSSL_NPN_NEGOTIATED) && !defined(OPENSSL_NO_NEXTPROTONEG)
`
2144
2144
`self->npn_protocols = NULL;
`
2145
2145
`#endif
`
2146
2146
`#ifdef HAVE_ALPN
`
`@@ -2218,7 +2218,7 @@ context_dealloc(PySSLContext *self)
`
2218
2218
`PyObject_GC_UnTrack(self);
`
2219
2219
`context_clear(self);
`
2220
2220
`SSL_CTX_free(self->ctx);
`
2221
``
`-
#ifdef OPENSSL_NPN_NEGOTIATED
`
``
2221
`+
#if defined(OPENSSL_NPN_NEGOTIATED) && !defined(OPENSSL_NO_NEXTPROTONEG)
`
2222
2222
`PyMem_FREE(self->npn_protocols);
`
2223
2223
`#endif
`
2224
2224
`#ifdef HAVE_ALPN
`
`@@ -2248,7 +2248,7 @@ set_ciphers(PySSLContext *self, PyObject *args)
`
2248
2248
`Py_RETURN_NONE;
`
2249
2249
`}
`
2250
2250
``
2251
``
`-
#ifdef OPENSSL_NPN_NEGOTIATED
`
``
2251
`+
#if defined(OPENSSL_NPN_NEGOTIATED) && !defined(OPENSSL_NO_NEXTPROTONEG) || defined(HAVE_ALPN)
`
2252
2252
`static int
`
2253
2253
`do_protocol_selection(int alpn, unsigned char **out, unsigned char *outlen,
`
2254
2254
`const unsigned char *server_protocols, unsigned int server_protocols_len,
`
`@@ -2272,7 +2272,9 @@ do_protocol_selection(int alpn, unsigned char **out, unsigned char *outlen,
`
2272
2272
``
2273
2273
`return SSL_TLSEXT_ERR_OK;
`
2274
2274
`}
`
``
2275
`+
#endif
`
2275
2276
``
``
2277
`+
#if defined(OPENSSL_NPN_NEGOTIATED) && !defined(OPENSSL_NO_NEXTPROTONEG)
`
2276
2278
`/* this callback gets passed to SSL_CTX_set_next_protos_advertise_cb */
`
2277
2279
`static int
`
2278
2280
`_advertiseNPN_cb(SSL *s,
`
`@@ -2307,7 +2309,7 @@ _selectNPN_cb(SSL *s,
`
2307
2309
`static PyObject *
`
2308
2310
`_set_npn_protocols(PySSLContext *self, PyObject *args)
`
2309
2311
`{
`
2310
``
`-
#ifdef OPENSSL_NPN_NEGOTIATED
`
``
2312
`+
#if defined(OPENSSL_NPN_NEGOTIATED) && !defined(OPENSSL_NO_NEXTPROTONEG)
`
2311
2313
`Py_buffer protos;
`
2312
2314
``
2313
2315
`if (!PyArg_ParseTuple(args, "s*:set_npn_protocols", &protos))
`
`@@ -4305,7 +4307,7 @@ init_ssl(void)
`
4305
4307
`Py_INCREF(r);
`
4306
4308
`PyModule_AddObject(m, "HAS_ECDH", r);
`
4307
4309
``
4308
``
`-
#ifdef OPENSSL_NPN_NEGOTIATED
`
``
4310
`+
#if defined(OPENSSL_NPN_NEGOTIATED) && !defined(OPENSSL_NO_NEXTPROTONEG)
`
4309
4311
`r = Py_True;
`
4310
4312
`#else
`
4311
4313
`r = Py_False;
`