@@ -3617,6 +3617,39 @@ set_maximum_version(PySSLContext *self, PyObject *arg, void *c)
36173617}
36183618#endif /* SSL_CTRL_GET_MAX_PROTO_VERSION */
36193619
3620+ #if (OPENSSL_VERSION_NUMBER >= 0x10101000L ) && !defined(LIBRESSL_VERSION_NUMBER )
3621+ static PyObject *
3622+ get_num_tickets (PySSLContext * self , void * c )
3623+ {
3624+ return PyLong_FromLong (SSL_CTX_get_num_tickets (self -> ctx ));
3625+ }
3626+
3627+ static int
3628+ set_num_tickets (PySSLContext * self , PyObject * arg , void * c )
3629+ {
3630+ long num ;
3631+ if (!PyArg_Parse (arg , "l" , & num ))
3632+ return -1 ;
3633+ if (num < 0 ) {
3634+ PyErr_SetString (PyExc_ValueError , "value must be non-negative" );
3635+ return -1 ;
3636+ }
3637+ if (self -> protocol != PY_SSL_VERSION_TLS_SERVER ) {
3638+ PyErr_SetString (PyExc_ValueError ,
3639+ "SSLContext is not a server context." );
3640+ return -1 ;
3641+ }
3642+ if (SSL_CTX_set_num_tickets (self -> ctx , num ) != 1 ) {
3643+ PyErr_SetString (PyExc_ValueError , "failed to set num tickets." );
3644+ return -1 ;
3645+ }
3646+ return 0 ;
3647+ }
3648+
3649+ PyDoc_STRVAR (PySSLContext_num_tickets_doc ,
3650+ "Control the number of TLSv1.3 session tickets" );
3651+ #endif /* OpenSSL 1.1.1 */
3652+
36203653static PyObject *
36213654get_options (PySSLContext * self , void * c )
36223655{
@@ -4654,6 +4687,10 @@ static PyGetSetDef context_getsetlist[] = {
46544687 (setter ) _PySSLContext_set_msg_callback , NULL },
46554688 {"sni_callback" , (getter ) get_sni_callback ,
46564689 (setter ) set_sni_callback , PySSLContext_sni_callback_doc },
4690+ #if (OPENSSL_VERSION_NUMBER >= 0x10101000L ) && !defined (LIBRESSL_VERSION_NUMBER )
4691+ {"num_tickets" , (getter ) get_num_tickets ,
4692+ (setter ) set_num_tickets , PySSLContext_num_tickets_doc },
4693+ #endif
46574694 {"options" , (getter ) get_options ,
46584695 (setter ) set_options , NULL },
46594696 {"post_handshake_auth" , (getter ) get_post_handshake_auth ,
0 commit comments