Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added SSL support to binary transport #445

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 21 additions & 1 deletion pyhive/hive.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import thrift.transport.THttpClient
import thrift.protocol.TBinaryProtocol
import thrift.transport.TSocket
import thrift.transport.TSSLSocket
import thrift.transport.TTransport

# PEP 249 module globals
Expand Down Expand Up @@ -101,6 +102,19 @@ def connect(*args, **kwargs):

:returns: a :py:class:`Connection` object.
"""
configuration = {}

keylist = list(kwargs)

if 'configuration' in keylist:
configuration = kwargs['configuration']

for arg in keylist:
if re.match('^EXTRA_',arg):
configuration[arg] = kwargs.pop(arg)

kwargs['configuration'] = configuration

return Connection(*args, **kwargs)


Expand Down Expand Up @@ -194,7 +208,13 @@ def __init__(
port = 10000
if auth is None:
auth = 'NONE'
socket = thrift.transport.TSocket.TSocket(host, port)

if 'EXTRA_USE_SSL' in configuration.keys():
socket = thrift.transport.TSSLSocket.TSSLSocket(host, port, cert_reqs=CERT_NONE)
22RC marked this conversation as resolved.
Show resolved Hide resolved
configuration.pop("EXTRA_USE_SSL")
else:
socket = thrift.transport.TSocket.TSocket(host, port)

if auth == 'NOSASL':
# NOSASL corresponds to hive.server2.authentication=NOSASL in hive-site.xml
self._transport = thrift.transport.TTransport.TBufferedTransport(socket)
Expand Down