File tree Expand file tree Collapse file tree 5 files changed +10
-41
lines changed
tests/integration/targets/mail/files Expand file tree Collapse file tree 5 files changed +10
-41
lines changed Original file line number Diff line number Diff line change 1+ minor_changes :
2+ - cobbler_sync - remove conditional code handling SSL for unsupported versions of Python (https://github.com/ansible-collections/community.general/pull/11078).
3+ - cobbler_system - remove conditional code handling SSL for unsupported versions of Python (https://github.com/ansible-collections/community.general/pull/11078).
4+ - jenkins_job_info - remove conditional code handling SSL for unsupported versions of Python (https://github.com/ansible-collections/community.general/pull/11078).
Original file line number Diff line number Diff line change @@ -110,22 +110,10 @@ def main():
110110
111111 start = now ()
112112
113- ssl_context = None
114- if not validate_certs :
115- try :
116- ssl_context = ssl ._create_unverified_context ()
117- except AttributeError :
118- # Legacy Python that doesn't verify HTTPS certificates by default
119- pass
120- else :
121- # Handle target environment that doesn't support HTTPS verification
122- ssl ._create_default_https_context = ssl ._create_unverified_context
113+ ssl_context = None if validate_certs or not use_ssl else ssl ._create_unverified_context ()
123114
124115 url = "{proto}://{host}:{port}/cobbler_api" .format (** module .params )
125- if ssl_context :
126- conn = xmlrpc_client .ServerProxy (url , context = ssl_context )
127- else :
128- conn = xmlrpc_client .Server (url )
116+ conn = xmlrpc_client .ServerProxy (url , context = ssl_context )
129117
130118 try :
131119 token = conn .login (username , password )
Original file line number Diff line number Diff line change @@ -232,22 +232,10 @@ def main():
232232
233233 start = now ()
234234
235- ssl_context = None
236- if not validate_certs :
237- try :
238- ssl_context = ssl ._create_unverified_context ()
239- except AttributeError :
240- # Legacy Python that doesn't verify HTTPS certificates by default
241- pass
242- else :
243- # Handle target environment that doesn't support HTTPS verification
244- ssl ._create_default_https_context = ssl ._create_unverified_context
235+ ssl_context = None if validate_certs or not use_ssl else ssl ._create_unverified_context ()
245236
246237 url = "{proto}://{host}:{port}/cobbler_api" .format (** module .params )
247- if ssl_context :
248- conn = xmlrpc_client .ServerProxy (url , context = ssl_context )
249- else :
250- conn = xmlrpc_client .Server (url )
238+ conn = xmlrpc_client .ServerProxy (url , context = ssl_context )
251239
252240 try :
253241 token = conn .login (username , password )
Original file line number Diff line number Diff line change @@ -160,13 +160,8 @@ def get_jenkins_connection(module):
160160 token = module .params .get ("token" )
161161
162162 validate_certs = module .params .get ("validate_certs" )
163- if not validate_certs and hasattr ( ssl , "SSLContext" ) :
163+ if not validate_certs :
164164 ssl ._create_default_https_context = ssl ._create_unverified_context
165- if validate_certs and not hasattr (ssl , "SSLContext" ):
166- module .fail_json (
167- msg = "Module does not support changing verification mode with python < 2.7.9."
168- " Either update Python or use validate_certs=false."
169- )
170165
171166 if username and (password or token ):
172167 return jenkins .Jenkins (url , username , password or token )
Original file line number Diff line number Diff line change 4141if len (sys .argv ) > 3 :
4242 keyfile = sys .argv [3 ]
4343
44- try :
45- ssl_ctx = ssl .create_default_context (ssl .Purpose .CLIENT_AUTH )
46- except AttributeError :
47- ssl_ctx = None
48- if HAS_TLS :
49- print ('Python ssl library does not support SSLContext, hence starttls and TLS are not supported.' )
50- import smtpd
44+ ssl_ctx = ssl .create_default_context (ssl .Purpose .CLIENT_AUTH )
5145
5246if HAS_TLS and ssl_ctx is not None :
5347 print ('Using %s and %s' % (certfile , keyfile ))
You can’t perform that action at this time.
0 commit comments