Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
78c7d527
Unverified
Kaydet (Commit)
78c7d527
authored
Haz 03, 2019
tarafından
Christian Heimes
Kaydeden (comit)
GitHub
Haz 03, 2019
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
bpo-37120: Add SSLContext.num_tickets (GH-13719)
Signed-off-by:
Christian Heimes
<
christian@python.org
>
üst
47eb2234
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
69 additions
and
0 deletions
+69
-0
ssl.rst
Doc/library/ssl.rst
+13
-0
test_ssl.py
Lib/test/test_ssl.py
+18
-0
2019-06-01-09-03-32.bpo-37120.FOKQLU.rst
...S.d/next/Library/2019-06-01-09-03-32.bpo-37120.FOKQLU.rst
+1
-0
_ssl.c
Modules/_ssl.c
+37
-0
No files found.
Doc/library/ssl.rst
Dosyayı görüntüle @
78c7d527
...
@@ -1959,6 +1959,19 @@ to speed up repeated connections from the same clients.
...
@@ -1959,6 +1959,19 @@ to speed up repeated connections from the same clients.
.. versionadded:: 3.7
.. versionadded:: 3.7
.. attribute:: SSLContext.num_tickets
Control the number of TLS 1.3 session tickets of a
:attr:`TLS_PROTOCOL_SERVER` context. The setting has no impact on TLS
1.0 to 1.2 connections.
.. note::
This attribute is not available unless the ssl module is compiled
with OpenSSL 1.1.1 or newer.
.. versionadded:: 3.8
.. attribute:: SSLContext.options
.. attribute:: SSLContext.options
An integer representing the set of SSL options enabled on this context.
An integer representing the set of SSL options enabled on this context.
...
...
Lib/test/test_ssl.py
Dosyayı görüntüle @
78c7d527
...
@@ -1634,6 +1634,24 @@ class ContextTests(unittest.TestCase):
...
@@ -1634,6 +1634,24 @@ class ContextTests(unittest.TestCase):
obj
=
ctx
.
wrap_bio
(
ssl
.
MemoryBIO
(),
ssl
.
MemoryBIO
())
obj
=
ctx
.
wrap_bio
(
ssl
.
MemoryBIO
(),
ssl
.
MemoryBIO
())
self
.
assertIsInstance
(
obj
,
MySSLObject
)
self
.
assertIsInstance
(
obj
,
MySSLObject
)
@unittest.skipUnless
(
IS_OPENSSL_1_1_1
,
"Test requires OpenSSL 1.1.1"
)
def
test_num_tickest
(
self
):
ctx
=
ssl
.
SSLContext
(
ssl
.
PROTOCOL_TLS_SERVER
)
self
.
assertEqual
(
ctx
.
num_tickets
,
2
)
ctx
.
num_tickets
=
1
self
.
assertEqual
(
ctx
.
num_tickets
,
1
)
ctx
.
num_tickets
=
0
self
.
assertEqual
(
ctx
.
num_tickets
,
0
)
with
self
.
assertRaises
(
ValueError
):
ctx
.
num_tickets
=
-
1
with
self
.
assertRaises
(
TypeError
):
ctx
.
num_tickets
=
None
ctx
=
ssl
.
SSLContext
(
ssl
.
PROTOCOL_TLS_CLIENT
)
self
.
assertEqual
(
ctx
.
num_tickets
,
2
)
with
self
.
assertRaises
(
ValueError
):
ctx
.
num_tickets
=
1
class
SSLErrorTests
(
unittest
.
TestCase
):
class
SSLErrorTests
(
unittest
.
TestCase
):
...
...
Misc/NEWS.d/next/Library/2019-06-01-09-03-32.bpo-37120.FOKQLU.rst
0 → 100644
Dosyayı görüntüle @
78c7d527
Add SSLContext.num_tickets to control the number of TLSv1.3 session tickets.
Modules/_ssl.c
Dosyayı görüntüle @
78c7d527
...
@@ -3617,6 +3617,39 @@ set_maximum_version(PySSLContext *self, PyObject *arg, void *c)
...
@@ -3617,6 +3617,39 @@ set_maximum_version(PySSLContext *self, PyObject *arg, void *c)
}
}
#endif
/* SSL_CTRL_GET_MAX_PROTO_VERSION */
#endif
/* SSL_CTRL_GET_MAX_PROTO_VERSION */
#if (OPENSSL_VERSION_NUMBER >= 0x10101000L) && !defined(LIBRESSL_VERSION_NUMBER)
static
PyObject
*
get_num_tickets
(
PySSLContext
*
self
,
void
*
c
)
{
return
PyLong_FromLong
(
SSL_CTX_get_num_tickets
(
self
->
ctx
));
}
static
int
set_num_tickets
(
PySSLContext
*
self
,
PyObject
*
arg
,
void
*
c
)
{
long
num
;
if
(
!
PyArg_Parse
(
arg
,
"l"
,
&
num
))
return
-
1
;
if
(
num
<
0
)
{
PyErr_SetString
(
PyExc_ValueError
,
"value must be non-negative"
);
return
-
1
;
}
if
(
self
->
protocol
!=
PY_SSL_VERSION_TLS_SERVER
)
{
PyErr_SetString
(
PyExc_ValueError
,
"SSLContext is not a server context."
);
return
-
1
;
}
if
(
SSL_CTX_set_num_tickets
(
self
->
ctx
,
num
)
!=
1
)
{
PyErr_SetString
(
PyExc_ValueError
,
"failed to set num tickets."
);
return
-
1
;
}
return
0
;
}
PyDoc_STRVAR
(
PySSLContext_num_tickets_doc
,
"Control the number of TLSv1.3 session tickets"
);
#endif
/* OpenSSL 1.1.1 */
static
PyObject
*
static
PyObject
*
get_options
(
PySSLContext
*
self
,
void
*
c
)
get_options
(
PySSLContext
*
self
,
void
*
c
)
{
{
...
@@ -4654,6 +4687,10 @@ static PyGetSetDef context_getsetlist[] = {
...
@@ -4654,6 +4687,10 @@ static PyGetSetDef context_getsetlist[] = {
(
setter
)
_PySSLContext_set_msg_callback
,
NULL
},
(
setter
)
_PySSLContext_set_msg_callback
,
NULL
},
{
"sni_callback"
,
(
getter
)
get_sni_callback
,
{
"sni_callback"
,
(
getter
)
get_sni_callback
,
(
setter
)
set_sni_callback
,
PySSLContext_sni_callback_doc
},
(
setter
)
set_sni_callback
,
PySSLContext_sni_callback_doc
},
#if (OPENSSL_VERSION_NUMBER >= 0x10101000L) && !defined(LIBRESSL_VERSION_NUMBER)
{
"num_tickets"
,
(
getter
)
get_num_tickets
,
(
setter
)
set_num_tickets
,
PySSLContext_num_tickets_doc
},
#endif
{
"options"
,
(
getter
)
get_options
,
{
"options"
,
(
getter
)
get_options
,
(
setter
)
set_options
,
NULL
},
(
setter
)
set_options
,
NULL
},
{
"post_handshake_auth"
,
(
getter
)
get_post_handshake_auth
,
{
"post_handshake_auth"
,
(
getter
)
get_post_handshake_auth
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment