def ssl_wrap_socket(sock, keyfile=None, certfile=None, cert_reqs=None,<EOL>ca_certs=None, server_hostname=None,<EOL>ssl_version=None, ciphers=None, ssl_context=None,<EOL>ca_cert_dir=None):
context = ssl_context<EOL>if context is None:<EOL><INDENT>context = create_urllib3_context(ssl_version, cert_reqs,<EOL>ciphers=ciphers)<EOL><DEDENT>if ca_certs or ca_cert_dir:<EOL><INDENT>try:<EOL><INDENT>context.load_verify_locations(ca_certs, ca_cert_dir)<EOL><DEDENT>except IOError as e:  <EOL><INDENT>raise SSLError(e)<EOL><DEDENT>except OSError as e:  <EOL><INDENT>if e.errno == errno.ENOENT:<EOL><INDENT>raise SSLError(e)<EOL><DEDENT>raise<EOL><DEDENT><DEDENT>elif getattr(context, '<STR_LIT>', None) is not None:<EOL><INDENT>context.load_default_certs()<EOL><DEDENT>if certfile:<EOL><INDENT>context.load_cert_chain(certfile, keyfile)<EOL><DEDENT>if ((server_hostname is not None and not is_ipaddress(server_hostname))<EOL>or IS_SECURETRANSPORT):<EOL><INDENT>if HAS_SNI and server_hostname is not None:<EOL><INDENT>return context.wrap_socket(sock, server_hostname=server_hostname)<EOL><DEDENT>warnings.warn(<EOL>'<STR_LIT>'<EOL>'<STR_LIT>'<EOL>'<STR_LIT>'<EOL>'<STR_LIT>'<EOL>'<STR_LIT>'<EOL>'<STR_LIT>'<EOL>'<STR_LIT>',<EOL>SNIMissingWarning<EOL>)<EOL><DEDENT>return context.wrap_socket(sock)<EOL>
All arguments except for server_hostname, ssl_context, and ca_cert_dir have
the same meaning as they do when using :func:`ssl.wrap_socket`.

:param server_hostname:
    When SNI is supported, the expected hostname of the certificate
:param ssl_context:
    A pre-made :class:`SSLContext` object. If none is provided, one will
    be created using :func:`create_urllib3_context`.
:param ciphers:
    A string of ciphers we wish the client to support.
:param ca_cert_dir:
    A directory containing CA certificates in multiple separate files, as
    supported by OpenSSL's -CApath flag or the capath argument to
    SSLContext.load_verify_locations().