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

How to provide certificate file when connecting to presto #87

Closed
trabbani opened this issue Aug 9, 2019 · 3 comments
Closed

How to provide certificate file when connecting to presto #87

trabbani opened this issue Aug 9, 2019 · 3 comments

Comments

@trabbani
Copy link

trabbani commented Aug 9, 2019

I am having this error:
(Caused by SSLError(SSLError("bad handshake: Error([('SSL routines', 'tls_process_server_certificate', 'certificate verify failed')])")))

when trying to connect to presto using the prestodb client

import prestodb

conn=prestodb.dbapi.connect(
    host='host.name',
    user='myuser',
    catalog='catalog',
    schema='schema',
    port='443',
    http_scheme='https'
)
cur = conn.cursor()
cur.execute('SELECT * FROM table limit 10')
rows = cur.fetchall()

In sqlalchamey I was able to make it work using this code:

engine_presto = create_engine(
    'presto://host.name:443',
    connect_args={
        'protocol': 'https',
        'requests_kwargs': {'verify': '/pat/to/cert.pem'}
    }
)

sql_str = 'SELECT * from table limit 10'
df = pd.read_sql(sql_str, con=engine_presto)

How can I provide my cert.pem file to the prestodb client

@trabbani
Copy link
Author

trabbani commented Aug 9, 2019

Found the solution:

with prestodb.dbapi.connect(
    host='host.namel',
    port=443,
    user='myuser',
    catalog='catalog',
    schema='schema',
    http_scheme='https'
) as conn:
    conn._http_session.verify = '/path/to/cert.pem'
    cur = conn.cursor()
    cur.execute(sql_str)

@cd1986
Copy link

cd1986 commented May 26, 2021

Found the solution:

with prestodb.dbapi.connect(
    host='host.namel',
    port=443,
    user='myuser',
    catalog='catalog',
    schema='schema',
    http_scheme='https'
) as conn:
    conn._http_session.verify = '/path/to/cert.pem'
    cur = conn.cursor()
    cur.execute(sql_str)

Hi Trabanni,

using the below script I am unable to connect the trino co-ordinator URL,
could you please help here?

#Python Client
import trino
conn = trino.dbapi.connect(
host ='[trino host]',
port = 8443,
user='[user]',
catalog ='[catalog]',
schema = '[schema]',
http_scheme = 'https',
auth=trino.auth.BasicAuthentication("[user]". "[password]"),
)
conn._http_session.verify = '[certificate path]'
cur = conn.cursor()
cur.execute('select * from hive.[catalog].[schema])

Error is:
++++++
could not find a suitable TLS CA certificate bundle, invalid path :/tmp/******.crt

@sgrbhinge
Copy link

Hello,

can somebody help with the same issue for providing cert file while connecting to Presto using node.js (with package presto-client). Currently I am facing error, unable to get local issuer certificate

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants