/
githubmirror
/
scrapy
Обзор
Документация
Войти
/
githubmirror
/
scrapy
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
2.14.2
tests/mockserver/utils.py
23 строки
724 B
Andrey Rakhmatullin
Extract in-process test HTTP servers into separate processes (#6960)
25 июл 2025, 10:42
Не верифицирован
25 июл 2025, 10:42
8c8f4ff
Код
Авторство
О чём код?
from __future__ import annotations from pathlib import Path from OpenSSL import SSL from twisted.internet import ssl from scrapy.utils.python import to_bytes def ssl_context_factory( keyfile="keys/localhost.key", certfile="keys/localhost.crt", cipher_string=None ): factory = ssl.DefaultOpenSSLContextFactory( str(Path(__file__).parent.parent / keyfile), str(Path(__file__).parent.parent / certfile), ) if cipher_string: ctx = factory.getContext() # disabling TLS1.3 because it unconditionally enables some strong ciphers ctx.set_options(SSL.OP_CIPHER_SERVER_PREFERENCE | SSL.OP_NO_TLSv1_3) ctx.set_cipher_list(to_bytes(cipher_string)) return factory