You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@libcloud.apache.org by to...@apache.org on 2016/06/27 18:11:04 UTC
[1/6] libcloud git commit: [LIBCLOUD-827] Add support for SNI
Repository: libcloud
Updated Branches:
refs/heads/trunk 9d1197e05 -> 7ea6b30b4
[LIBCLOUD-827] Add support for SNI
Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo
Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/c715b78e
Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/c715b78e
Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/c715b78e
Branch: refs/heads/trunk
Commit: c715b78e52b7e8bb20d858fb58cd7ad9565d182f
Parents: 76cc0bb
Author: lochiiconnectivity <lc...@convergence.cx>
Authored: Tue Jun 7 21:01:09 2016 +0000
Committer: lochiiconnectivity <lc...@convergence.cx>
Committed: Tue Jun 7 23:41:42 2016 +0000
----------------------------------------------------------------------
libcloud/httplib_ssl.py | 53 ++++++++++++++++++++++++++--------
libcloud/test/test_httplib_ssl.py | 14 +++++++--
2 files changed, 53 insertions(+), 14 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/libcloud/blob/c715b78e/libcloud/httplib_ssl.py
----------------------------------------------------------------------
diff --git a/libcloud/httplib_ssl.py b/libcloud/httplib_ssl.py
index b3e3101..a809c16 100644
--- a/libcloud/httplib_ssl.py
+++ b/libcloud/httplib_ssl.py
@@ -292,21 +292,50 @@ class LibcloudHTTPSConnection(httplib.HTTPSConnection, LibcloudBaseConnection):
ssl_version = libcloud.security.SSL_VERSION
+ # Connect, using contexts and SNI if we can
+
try:
- self.sock = ssl.wrap_socket(
- sock,
- self.key_file,
- self.cert_file,
- cert_reqs=ssl.CERT_REQUIRED,
- ca_certs=self.ca_cert,
- ssl_version=ssl_version)
- except socket.error:
- exc = sys.exc_info()[1]
- # Re-throw an exception with a more friendly error message
- exc = get_socket_error_exception(ssl_version=ssl_version, exc=exc)
- raise exc
+ self.tls_context = ssl.SSLContext(ssl_version)
+ self.tls_context.verify_mode = ssl.CERT_REQUIRED
+ if self.cert_file and self.key_file:
+ self.tls_context.load_cert_chain(
+ self.cert_file, self.key_file, None)
+ if self.ca_cert:
+ self.tls_context.load_verify_locations(self.ca_cert)
+ except AttributeError:
+ self.tls_context = None
+
+ if self.tls_context and ssl.HAS_SNI:
+ try:
+ self.sock = self.tls_context.wrap_socket(
+ sock,
+ server_hostname=self.host,
+ )
+ except:
+ exc = sys.exc_info()[1]
+ exc = get_socket_error_exception(ssl_version=ssl_version,
+ exc=exc)
+ raise exc
+ else:
+ try:
+ self.sock = ssl.wrap_socket(
+ sock,
+ self.key_file,
+ self.cert_file,
+ cert_reqs=ssl.CERT_REQUIRED,
+ ca_certs=self.ca_cert,
+ ssl_version=ssl_version
+ )
+ except:
+ exc = sys.exc_info()[1]
+ exc = get_socket_error_exception(ssl_version=ssl_version,
+ exc=exc)
+ raise exc
cert = self.sock.getpeercert()
+
+ # Verify Hostname
+
try:
match_hostname(cert, self.host)
except CertificateError:
http://git-wip-us.apache.org/repos/asf/libcloud/blob/c715b78e/libcloud/test/test_httplib_ssl.py
----------------------------------------------------------------------
diff --git a/libcloud/test/test_httplib_ssl.py b/libcloud/test/test_httplib_ssl.py
index 996498f..02e64ed 100644
--- a/libcloud/test/test_httplib_ssl.py
+++ b/libcloud/test/test_httplib_ssl.py
@@ -16,6 +16,7 @@
import os
import sys
import os.path
+import ssl
import socket
import mock
@@ -109,8 +110,17 @@ class TestHttpLibSSLTests(unittest.TestCase):
@mock.patch('socket.create_connection', mock.MagicMock())
@mock.patch('socket.socket', mock.MagicMock())
- @mock.patch('ssl.wrap_socket')
- def test_connect_throws_friendly_error_message_on_ssl_wrap_connection_reset_by_peer(self, mock_wrap_socket):
+ def test_connect_throws_friendly_error_message_on_ssl_wrap_connection_reset_by_peer(self):
+
+ mock_wrap_socket = None
+
+ if getattr(ssl, 'SSLContext', None):
+ ssl.SSLContext.wrap_socket = mock.MagicMock()
+ mock_wrap_socket = ssl.SSLContext.wrap_socket
+ else:
+ ssl.wrap_socket = mock.MagicMock()
+ mock_wrap_socket = ssl.wrap_socket
+
# Test that we re-throw a more friendly error message in case
# "connection reset by peer" error occurs when trying to establish a
# SSL connection
[4/6] libcloud git commit: Some code cleanup and refactor.
Posted by to...@apache.org.
Some code cleanup and refactor.
Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo
Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/d9cbef07
Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/d9cbef07
Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/d9cbef07
Branch: refs/heads/trunk
Commit: d9cbef07b8d099b9c447ef161e91c7caca4c4182
Parents: 85c062d
Author: Tomaz Muraus <to...@tomaz.me>
Authored: Mon Jun 27 19:44:35 2016 +0200
Committer: Tomaz Muraus <to...@tomaz.me>
Committed: Mon Jun 27 20:01:39 2016 +0200
----------------------------------------------------------------------
libcloud/httplib_ssl.py | 18 ++++++++++++++----
1 file changed, 14 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/libcloud/blob/d9cbef07/libcloud/httplib_ssl.py
----------------------------------------------------------------------
diff --git a/libcloud/httplib_ssl.py b/libcloud/httplib_ssl.py
index cc927fe..bbcf752 100644
--- a/libcloud/httplib_ssl.py
+++ b/libcloud/httplib_ssl.py
@@ -12,10 +12,12 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
+
"""
Subclass for httplib.HTTPSConnection with optional certificate name
verification, depending on libcloud.security settings.
"""
+
import os
import sys
import socket
@@ -294,15 +296,23 @@ class LibcloudHTTPSConnection(httplib.HTTPSConnection, LibcloudBaseConnection):
# If we support SNI, use SSLContext and tls_context.wrap_socket()
# else revert to older behaviour with ssl.wrap_socket()
+ # Note: This feature is only available in Python 2.7.9 and
+ # Python >= 3.2
+ has_sni = getattr(ssl, 'HAS_SNI', False)
- if getattr(ssl, 'HAS_SNI', False):
+ if has_sni:
self.tls_context = ssl.SSLContext(ssl_version)
self.tls_context.verify_mode = ssl.CERT_REQUIRED
+
if self.cert_file and self.key_file:
self.tls_context.load_cert_chain(
- self.cert_file, self.key_file, None)
+ certfile=self.cert_file,
+ keyfile=self.key_file,
+ password=None)
+
if self.ca_cert:
- self.tls_context.load_verify_locations(self.ca_cert)
+ self.tls_context.load_verify_locations(cafile=self.ca_cert)
+
try:
self.sock = self.tls_context.wrap_socket(
sock,
@@ -314,6 +324,7 @@ class LibcloudHTTPSConnection(httplib.HTTPSConnection, LibcloudBaseConnection):
exc=exc)
raise exc
else:
+ # SNI support not available
try:
self.sock = ssl.wrap_socket(
sock,
@@ -332,7 +343,6 @@ class LibcloudHTTPSConnection(httplib.HTTPSConnection, LibcloudBaseConnection):
cert = self.sock.getpeercert()
# Verify Hostname
-
try:
match_hostname(cert, self.host)
except CertificateError:
[6/6] libcloud git commit: Temporary disable coverage support in tox
target since it breaks tests under Python 2.6.
Posted by to...@apache.org.
Temporary disable coverage support in tox target since it breaks tests under
Python 2.6.
Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo
Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/7ea6b30b
Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/7ea6b30b
Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/7ea6b30b
Branch: refs/heads/trunk
Commit: 7ea6b30b4a20f0bd8f11d955cf02b6b81d784a55
Parents: f93878c
Author: Tomaz Muraus <to...@tomaz.me>
Authored: Mon Jun 27 19:52:32 2016 +0200
Committer: Tomaz Muraus <to...@tomaz.me>
Committed: Mon Jun 27 20:01:51 2016 +0200
----------------------------------------------------------------------
tox.ini | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/libcloud/blob/7ea6b30b/tox.ini
----------------------------------------------------------------------
diff --git a/tox.ini b/tox.ini
index b296448..248b102 100644
--- a/tox.ini
+++ b/tox.ini
@@ -11,8 +11,9 @@ deps =
set-env =
COVERALLS_REPO_TOKEN = GAB5ZuovdsVEFxSIyZE8YhDYU886iGW54
commands = cp libcloud/test/secrets.py-dist libcloud/test/secrets.py
- coverage run --source=libcloud setup.py test
- coveralls
+ python setup.py test
+# coverage run --source=libcloud setup.py test
+# coveralls
basepython =
py2.5: python2.5
py2.6: python2.6
[3/6] libcloud git commit: Merge remote-tracking branch 'lc/827_SNI'
into trunk
Posted by to...@apache.org.
Merge remote-tracking branch 'lc/827_SNI' into trunk
Closes #808
Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo
Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/85c062df
Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/85c062df
Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/85c062df
Branch: refs/heads/trunk
Commit: 85c062dfe50b4631e93082b83f7357ac00b646ef
Parents: 9d1197e 151a975
Author: Tomaz Muraus <to...@tomaz.me>
Authored: Mon Jun 27 20:00:25 2016 +0200
Committer: Tomaz Muraus <to...@tomaz.me>
Committed: Mon Jun 27 20:00:29 2016 +0200
----------------------------------------------------------------------
libcloud/httplib_ssl.py | 52 +++++++++++++++++++++++++---------
libcloud/test/test_httplib_ssl.py | 14 +++++++--
2 files changed, 51 insertions(+), 15 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/libcloud/blob/85c062df/libcloud/test/test_httplib_ssl.py
----------------------------------------------------------------------
[2/6] libcloud git commit: Fix Style by request
Posted by to...@apache.org.
Fix Style by request
Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo
Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/151a9756
Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/151a9756
Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/151a9756
Branch: refs/heads/trunk
Commit: 151a9756704b6bfad415dbd4da07306591cc0f04
Parents: c715b78
Author: lochiiconnectivity <lc...@convergence.cx>
Authored: Sun Jun 26 19:03:27 2016 +0000
Committer: lochiiconnectivity <lc...@convergence.cx>
Committed: Sun Jun 26 19:21:42 2016 +0000
----------------------------------------------------------------------
libcloud/httplib_ssl.py | 9 +++------
libcloud/test/test_httplib_ssl.py | 2 +-
2 files changed, 4 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/libcloud/blob/151a9756/libcloud/httplib_ssl.py
----------------------------------------------------------------------
diff --git a/libcloud/httplib_ssl.py b/libcloud/httplib_ssl.py
index a809c16..cc927fe 100644
--- a/libcloud/httplib_ssl.py
+++ b/libcloud/httplib_ssl.py
@@ -292,9 +292,10 @@ class LibcloudHTTPSConnection(httplib.HTTPSConnection, LibcloudBaseConnection):
ssl_version = libcloud.security.SSL_VERSION
- # Connect, using contexts and SNI if we can
+ # If we support SNI, use SSLContext and tls_context.wrap_socket()
+ # else revert to older behaviour with ssl.wrap_socket()
- try:
+ if getattr(ssl, 'HAS_SNI', False):
self.tls_context = ssl.SSLContext(ssl_version)
self.tls_context.verify_mode = ssl.CERT_REQUIRED
if self.cert_file and self.key_file:
@@ -302,10 +303,6 @@ class LibcloudHTTPSConnection(httplib.HTTPSConnection, LibcloudBaseConnection):
self.cert_file, self.key_file, None)
if self.ca_cert:
self.tls_context.load_verify_locations(self.ca_cert)
- except AttributeError:
- self.tls_context = None
-
- if self.tls_context and ssl.HAS_SNI:
try:
self.sock = self.tls_context.wrap_socket(
sock,
http://git-wip-us.apache.org/repos/asf/libcloud/blob/151a9756/libcloud/test/test_httplib_ssl.py
----------------------------------------------------------------------
diff --git a/libcloud/test/test_httplib_ssl.py b/libcloud/test/test_httplib_ssl.py
index 02e64ed..38f6ac8 100644
--- a/libcloud/test/test_httplib_ssl.py
+++ b/libcloud/test/test_httplib_ssl.py
@@ -114,7 +114,7 @@ class TestHttpLibSSLTests(unittest.TestCase):
mock_wrap_socket = None
- if getattr(ssl, 'SSLContext', None):
+ if getattr(ssl, 'HAS_SNI', False):
ssl.SSLContext.wrap_socket = mock.MagicMock()
mock_wrap_socket = ssl.SSLContext.wrap_socket
else:
[5/6] libcloud git commit: Update changelog.
Posted by to...@apache.org.
Update changelog.
Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo
Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/f93878c7
Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/f93878c7
Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/f93878c7
Branch: refs/heads/trunk
Commit: f93878c763244c21acca26be6135cf6902aa0d51
Parents: d9cbef0
Author: Tomaz Muraus <to...@tomaz.me>
Authored: Mon Jun 27 19:46:49 2016 +0200
Committer: Tomaz Muraus <to...@tomaz.me>
Committed: Mon Jun 27 20:01:45 2016 +0200
----------------------------------------------------------------------
CHANGES.rst | 11 +++++++++++
1 file changed, 11 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/libcloud/blob/f93878c7/CHANGES.rst
----------------------------------------------------------------------
diff --git a/CHANGES.rst b/CHANGES.rst
index 44e689f..c58ec3d 100644
--- a/CHANGES.rst
+++ b/CHANGES.rst
@@ -4,6 +4,17 @@
Changes with Apache Libcloud in development
-------------------------------------------
+General
+~~~~~~~
+
+- Add support for automatic SNI (SSL extension) using the hostname
+ supplied to connect to.
+
+ Note: This functionality is only available in Python 2.7.9 and
+ Python >= 3.2.
+ (LIBCLOUD-827, GITHUB-808)
+ [David Freedman]
+
Compute
~~~~~~~