@@ -2168,20 +2168,24 @@ def test_protocol_sslv23(self):
21682168 sys .stdout .write (
21692169 " SSL2 client to SSL23 server test unexpectedly failed:\n %s\n "
21702170 % str (x ))
2171- try_protocol_combo (ssl .PROTOCOL_SSLv23 , ssl .PROTOCOL_SSLv3 , True )
2171+ if hasattr (ssl , 'PROTOCOL_SSLv3' ):
2172+ try_protocol_combo (ssl .PROTOCOL_SSLv23 , ssl .PROTOCOL_SSLv3 , True )
21722173 try_protocol_combo (ssl .PROTOCOL_SSLv23 , ssl .PROTOCOL_SSLv23 , True )
21732174 try_protocol_combo (ssl .PROTOCOL_SSLv23 , ssl .PROTOCOL_TLSv1 , True )
21742175
2175- try_protocol_combo (ssl .PROTOCOL_SSLv23 , ssl .PROTOCOL_SSLv3 , True , ssl .CERT_OPTIONAL )
2176+ if hasattr (ssl , 'PROTOCOL_SSLv3' ):
2177+ try_protocol_combo (ssl .PROTOCOL_SSLv23 , ssl .PROTOCOL_SSLv3 , True , ssl .CERT_OPTIONAL )
21762178 try_protocol_combo (ssl .PROTOCOL_SSLv23 , ssl .PROTOCOL_SSLv23 , True , ssl .CERT_OPTIONAL )
21772179 try_protocol_combo (ssl .PROTOCOL_SSLv23 , ssl .PROTOCOL_TLSv1 , True , ssl .CERT_OPTIONAL )
21782180
2179- try_protocol_combo (ssl .PROTOCOL_SSLv23 , ssl .PROTOCOL_SSLv3 , True , ssl .CERT_REQUIRED )
2181+ if hasattr (ssl , 'PROTOCOL_SSLv3' ):
2182+ try_protocol_combo (ssl .PROTOCOL_SSLv23 , ssl .PROTOCOL_SSLv3 , True , ssl .CERT_REQUIRED )
21802183 try_protocol_combo (ssl .PROTOCOL_SSLv23 , ssl .PROTOCOL_SSLv23 , True , ssl .CERT_REQUIRED )
21812184 try_protocol_combo (ssl .PROTOCOL_SSLv23 , ssl .PROTOCOL_TLSv1 , True , ssl .CERT_REQUIRED )
21822185
21832186 # Server with specific SSL options
2184- try_protocol_combo (ssl .PROTOCOL_SSLv23 , ssl .PROTOCOL_SSLv3 , False ,
2187+ if hasattr (ssl , 'PROTOCOL_SSLv3' ):
2188+ try_protocol_combo (ssl .PROTOCOL_SSLv23 , ssl .PROTOCOL_SSLv3 , False ,
21852189 server_options = ssl .OP_NO_SSLv3 )
21862190 # Will choose TLSv1
21872191 try_protocol_combo (ssl .PROTOCOL_SSLv23 , ssl .PROTOCOL_SSLv23 , True ,
@@ -2191,6 +2195,8 @@ def test_protocol_sslv23(self):
21912195
21922196
21932197 @skip_if_broken_ubuntu_ssl
2198+ @unittest .skipUnless (hasattr (ssl , 'PROTOCOL_SSLv3' ),
2199+ "OpenSSL is compiled without SSLv3 support" )
21942200 def test_protocol_sslv3 (self ):
21952201 """Connecting to an SSLv3 server with various client options"""
21962202 if support .verbose :
@@ -2218,7 +2224,8 @@ def test_protocol_tlsv1(self):
22182224 try_protocol_combo (ssl .PROTOCOL_TLSv1 , ssl .PROTOCOL_TLSv1 , True , ssl .CERT_REQUIRED )
22192225 if hasattr (ssl , 'PROTOCOL_SSLv2' ):
22202226 try_protocol_combo (ssl .PROTOCOL_TLSv1 , ssl .PROTOCOL_SSLv2 , False )
2221- try_protocol_combo (ssl .PROTOCOL_TLSv1 , ssl .PROTOCOL_SSLv3 , False )
2227+ if hasattr (ssl , 'PROTOCOL_SSLv3' ):
2228+ try_protocol_combo (ssl .PROTOCOL_TLSv1 , ssl .PROTOCOL_SSLv3 , False )
22222229 try_protocol_combo (ssl .PROTOCOL_TLSv1 , ssl .PROTOCOL_SSLv23 , False ,
22232230 client_options = ssl .OP_NO_TLSv1 )
22242231
@@ -2233,7 +2240,8 @@ def test_protocol_tlsv1_1(self):
22332240 try_protocol_combo (ssl .PROTOCOL_TLSv1_1 , ssl .PROTOCOL_TLSv1_1 , True )
22342241 if hasattr (ssl , 'PROTOCOL_SSLv2' ):
22352242 try_protocol_combo (ssl .PROTOCOL_TLSv1_1 , ssl .PROTOCOL_SSLv2 , False )
2236- try_protocol_combo (ssl .PROTOCOL_TLSv1_1 , ssl .PROTOCOL_SSLv3 , False )
2243+ if hasattr (ssl , 'PROTOCOL_SSLv3' ):
2244+ try_protocol_combo (ssl .PROTOCOL_TLSv1_1 , ssl .PROTOCOL_SSLv3 , False )
22372245 try_protocol_combo (ssl .PROTOCOL_TLSv1_1 , ssl .PROTOCOL_SSLv23 , False ,
22382246 client_options = ssl .OP_NO_TLSv1_1 )
22392247
@@ -2255,7 +2263,8 @@ def test_protocol_tlsv1_2(self):
22552263 client_options = ssl .OP_NO_SSLv3 | ssl .OP_NO_SSLv2 ,)
22562264 if hasattr (ssl , 'PROTOCOL_SSLv2' ):
22572265 try_protocol_combo (ssl .PROTOCOL_TLSv1_2 , ssl .PROTOCOL_SSLv2 , False )
2258- try_protocol_combo (ssl .PROTOCOL_TLSv1_2 , ssl .PROTOCOL_SSLv3 , False )
2266+ if hasattr (ssl , 'PROTOCOL_SSLv3' ):
2267+ try_protocol_combo (ssl .PROTOCOL_TLSv1_2 , ssl .PROTOCOL_SSLv3 , False )
22592268 try_protocol_combo (ssl .PROTOCOL_TLSv1_2 , ssl .PROTOCOL_SSLv23 , False ,
22602269 client_options = ssl .OP_NO_TLSv1_2 )
22612270
0 commit comments