Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
ansible
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
OpenEdx
ansible
Commits
d240d073
Commit
d240d073
authored
Apr 15, 2014
by
James Cammarata
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Changing SSL cert detection method to allow for auto-negotiation of SSL protocols
Fixes #6904
parent
23c5f452
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
5 deletions
+14
-5
lib/ansible/module_utils/urls.py
+14
-5
No files found.
lib/ansible/module_utils/urls.py
View file @
d240d073
...
@@ -50,6 +50,7 @@ try:
...
@@ -50,6 +50,7 @@ try:
except
:
except
:
HAS_SSL
=
False
HAS_SSL
=
False
import
socket
import
tempfile
import
tempfile
...
@@ -162,12 +163,20 @@ class SSLValidationHandler(urllib2.BaseHandler):
...
@@ -162,12 +163,20 @@ class SSLValidationHandler(urllib2.BaseHandler):
def
http_request
(
self
,
req
):
def
http_request
(
self
,
req
):
tmp_ca_cert_path
,
paths_checked
=
self
.
get_ca_certs
()
tmp_ca_cert_path
,
paths_checked
=
self
.
get_ca_certs
()
try
:
try
:
server_cert
=
ssl
.
get_server_certificate
((
self
.
hostname
,
self
.
port
),
ca_certs
=
tmp_ca_cert_path
)
s
=
socket
.
socket
(
socket
.
AF_INET
,
socket
.
SOCK_STREAM
)
except
ssl
.
SSLError
:
ssl_s
=
ssl
.
wrap_socket
(
s
,
ca_certs
=
tmp_ca_cert_path
,
cert_reqs
=
ssl
.
CERT_REQUIRED
)
ssl_s
.
connect
((
self
.
hostname
,
self
.
port
))
ssl_s
.
close
()
except
(
ssl
.
SSLError
,
socket
.
error
),
e
:
# fail if we tried all of the certs but none worked
# fail if we tried all of the certs but none worked
self
.
module
.
fail_json
(
msg
=
'Failed to validate the SSL certificate for
%
s:
%
s. '
%
(
self
.
hostname
,
self
.
port
)
+
\
if
'connection refused'
in
str
(
e
)
.
lower
():
'Use validate_certs=no or make sure your managed systems have a valid CA certificate installed. '
+
\
self
.
module
.
fail_json
(
msg
=
'Failed to connect to
%
s:
%
s.'
%
(
self
.
hostname
,
self
.
port
))
'Paths checked for this platform:
%
s'
%
", "
.
join
(
paths_checked
))
else
:
self
.
module
.
fail_json
(
msg
=
'Failed to validate the SSL certificate for
%
s:
%
s. '
%
(
self
.
hostname
,
self
.
port
)
+
\
'Use validate_certs=no or make sure your managed systems have a valid CA certificate installed. '
+
\
'Paths checked for this platform:
%
s'
%
", "
.
join
(
paths_checked
)
)
try
:
try
:
# cleanup the temp file created, don't worry
# cleanup the temp file created, don't worry
# if it fails for some reason
# if it fails for some reason
...
...
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