Created
December 11, 2016 01:30
-
-
Save tomprince/4ff9f25b94c7a57a0275a6ecc1d22b58 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/src/twisted/internet/_sslverify.py b/src/twisted/internet/_sslverify.py | |
index b62ccc5..7535297 100644 | |
--- a/src/twisted/internet/_sslverify.py | |
+++ b/src/twisted/internet/_sslverify.py | |
@@ -24,32 +24,27 @@ from twisted.python._oldstyle import _oldStyle | |
from ._idna import _idnaBytes | |
+import attr | |
- | |
-class TLSVersion(Names): | |
- """ | |
- TLS versions that we can negotiate with the client/server. | |
- """ | |
- SSLv3 = NamedConstant() | |
- TLSv1_0 = NamedConstant() | |
- TLSv1_1 = NamedConstant() | |
- TLSv1_2 = NamedConstant() | |
- TLSv1_3 = NamedConstant() | |
+@attr.s | |
+class _TLSData(object): | |
+ disableFlag = attr.ib( | |
-_tlsDisableFlags = { | |
- TLSVersion.SSLv3: SSL.OP_NO_SSLv3, | |
- TLSVersion.TLSv1_0: SSL.OP_NO_TLSv1, | |
- TLSVersion.TLSv1_1: SSL.OP_NO_TLSv1_1, | |
- TLSVersion.TLSv1_2: SSL.OP_NO_TLSv1_2, | |
+class TLSVersion(Values): | |
+ """ | |
+ TLS versions that we can negotiate with the client/server. | |
+ """ | |
+ SSLv3 = ValueConstant(_TLSData(disableFlag=SSL.OP_NO_SSLv3)) | |
+ TLSv1_0 = ValueConstant(_TLSData(disableFlag=SSL.OP_NO_TLSv1, )) | |
+ TLSv1_1 = ValueConstant(_TLSData(disableFlag=SSL.OP_NO_TLSv1_1,)) | |
+ TLSv1_2 = ValueConstant(_TLSData(disableFlag=SSL.OP_NO_TLSv1_2,)) | |
# If we don't have TLS v1.3 yet, we can't disable it -- this is just so | |
# when it makes it into OpenSSL, connections knowingly bracketed to v1.2 | |
# don't end up going to v1.3 | |
- TLSVersion.TLSv1_3: getattr(SSL, "OP_NO_TLSv1_3", 0x00), | |
-} | |
- | |
+ TLSv1_3 = ValueConstant(_TLSData(disableFlag=getattr(SSL, "OP_NO_TLSv1_3", 0x00))) | |
def _getExcludedTLSProtocols(oldest, newest): |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment