Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def _ssl_wrap_socket(self, sock):
"""Wrap SSLSocket around the Socket.
:param socket.socket sock:
:rtype: SSLSocket
"""
if 'ssl_version' not in self._parameters['ssl_options']:
self._parameters['ssl_options']['ssl_version'] = \
compatibility.DEFAULT_SSL_VERSION
return ssl.wrap_socket(sock, do_handshake_on_connect=True,
**self._parameters['ssl_options'])
def _ssl_wrap_socket(self, sock):
"""Wrap SSLSocket around the Socket.
:param socket.socket sock:
:rtype: SSLSocket
"""
if 'ssl_version' not in self._parameters['ssl_options']:
self._parameters['ssl_options']['ssl_version'] = \
compatibility.DEFAULT_SSL_VERSION
return ssl.wrap_socket(sock, do_handshake_on_connect=True,
**self._parameters['ssl_options'])
:param socket.socket sock:
:rtype: SSLSocket
"""
context = self._parameters['ssl_options'].get('context')
if context is not None:
hostname = self._parameters['ssl_options'].get('server_hostname')
return context.wrap_socket(
sock, do_handshake_on_connect=True,
server_hostname=hostname
)
if 'ssl_version' not in self._parameters['ssl_options']:
self._parameters['ssl_options']['ssl_version'] = (
compatibility.DEFAULT_SSL_VERSION
)
return ssl.wrap_socket(
sock, do_handshake_on_connect=True,
**self._parameters['ssl_options']
)