superset icon indicating copy to clipboard operation
superset copied to clipboard

Unable to connect to presto-coordinator using SSL

Open bharath0208 opened this issue 6 years ago • 20 comments

Hi Folks,

I am trying to connect to my presto coordinator from superset over https but i am getting this error. superset_1 | requests.exceptions.SSLError: HTTPSConnectionPool(host='**************.cloud', port=443): Max retries exceeded with url: /v1/statement (Caused by SSLError(SSLError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:852)'),))

Expected results

This is expected to connect to my presto-coordinator which is running on https port

  • superset version: Latest
  • python version: 3.6.9
  • node.js version: v10.17.0
  • npm version: 6.11.3
  • pip version: pip 9.0.2 from /usr/local/lib/python3.6/site-packages (python 3.6)

Parameters Used

SQLAlchemy URI: presto://<presto_coordinator>://information_schema?source=superset\

Extra: { "metadata_params": {}, "engine_params": { "connect_args":{ "protocol": "https", "requests_kwargs": { "verify": "/home/superset/tls.pem" } } }, "metadata_cache_timeout": {}, "schemas_allowed_for_csv_upload": []

Checklist

Make sure these boxes are checked before submitting your issue - thank you!

  • [x] I have checked the superset logs for python stack traces and included it here as text if there are any.
  • [x] I have reproduced the issue with at least the latest released version of the superset.
  • [x] I have checked the issue tracker for the same issue and I haven't found one similar.

bharath0208 avatar Dec 02 '19 18:12 bharath0208

Issue Label Bot is not confident enough to auto-label this issue. See dashboard for more details.

issue-label-bot[bot] avatar Dec 02 '19 18:12 issue-label-bot[bot]

Issue Label Bot is not confident enough to auto-label this issue. See dashboard for more details.

i want to post this as a question @issue-label-bot

bharath0208 avatar Dec 04 '19 16:12 bharath0208

🏷 question

betodealmeida avatar Dec 04 '19 17:12 betodealmeida

Looks like requests_kwargs is not being passed to requests, let me take a look.

betodealmeida avatar Dec 04 '19 17:12 betodealmeida

@betodealmeida is there any way to enable debugging mode for superset

bharath0208 avatar Dec 04 '19 21:12 bharath0208

Is this because i am not using a self signed certificate. I am actually using certificate provided by my cloud kubernetes team. Since my presto app is deployed in kubernetes. I am using those certificates in superset as well. @betodealmeida

bharath0208 avatar Dec 09 '19 15:12 bharath0208

Had to look this up, FYI: https://github.com/dropbox/PyHive/blob/6925cd74721cc474a02a6759490b2b4c8bef3831/pyhive/presto.py#L107

mistercrunch avatar Dec 10 '19 06:12 mistercrunch

@mistercrunch didn't quite get it. What do you mean? Can u brief up a little bit pls

bharath0208 avatar Dec 10 '19 07:12 bharath0208

Just for sanity check on @betodealmeida investigation around request_kwargs being passed to requests, can you please make a test with "verify": false and report back?

dpgaspar avatar Dec 10 '19 16:12 dpgaspar

@dpgaspar

I tried with "verify": false

superset_1         | b'<html>\n<head>\n<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>\n<title>Error 401 Unauthorized</title>\n</head>\n<body><h2>HTTP ERROR 401</h2>\n<p>Problem accessing /v1/statement. Reason:\n<pre>    Unauthorized</pre></p>\n</body>\n</html>\n'
superset_1         | [SQL: SELECT 1]
superset_1         | (Background on this error at: http://sqlalche.me/e/e3q8)
superset_1         | 172.22.0.1 - - [10/Dec/2019 17:48:42] "POST /superset/testconn HTTP/1.1" 500 -

Also, i tried "verify": "false" and I am getting the below error.

superset_1         |     "invalid path: {}".format(cert_loc))
superset_1         | OSError: Could not find a suitable TLS CA certificate bundle, invalid path: false
superset_1         | 172.22.0.1 - - [10/Dec/2019 17:50:19] "POST /superset/testconn HTTP/1.1" 500 -```

bharath0208 avatar Dec 10 '19 17:12 bharath0208

Thank you, I think that helps, seems like request_kwargs is actually getting at the requests pkg, the first error is interesting, would risk saying you don't have access to presto (credentials).

dpgaspar avatar Dec 10 '19 19:12 dpgaspar

@dpgaspar Is there any way that we can pass jks file instead of PEM file for the SSL to happen b/w presto and superset. The Keystore file was earlier working for us with another tool.

bharath0208 avatar Dec 10 '19 19:12 bharath0208

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. For admin, please label this issue .pinned to prevent stale bot from closing the issue.

stale[bot] avatar Feb 08 '20 19:02 stale[bot]

Hi! I think that we should re-open this issue, I am currently testing the new version of PyHive with a self signed certificate and it doesn't work. More specifically, I don't see any difference if I set requests_kwargs among the extras. I failed also to pass it via sql alchemy URL.

As @mistercrunch mentioned, https://github.com/dropbox/PyHive/blob/6925cd74721cc474a02a6759490b2b4c8bef3831/pyhive/presto.py#L107 is a good starting point, but I haven't figure out yet where a Cursor is used in Superset and how to see if requests_kwarg is passed.

elukey avatar Mar 05 '20 13:03 elukey

After some tries I think that something like the following works:

    "engine_params": {
        "connect_args": {
             "requests_kwargs": {
                 "verify": "/some/path/to/ca"
             }
       }

elukey avatar Mar 05 '20 14:03 elukey

This works fine for me now. You need to ensure that the cert is in .PEM format only. One way to find our the pem file which is working is you can do a curl -v https://presto-ui name this would give you a pem file in your local desktop. You can use this .PEM file to connect via superset also.

{
        "metadata_params": {},
        "engine_params": {
           "connect_args":{
              "protocol": "https",
              "requests_kwargs": {
                       "verify": "path.pem"
                }
           }
         },
        "metadata_cache_timeout": {},
        "schemas_allowed_for_csv_upload": []
    }

bharath0208 avatar Mar 05 '20 17:03 bharath0208

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. For admin, please label this issue .pinned to prevent stale bot from closing the issue.

stale[bot] avatar May 06 '20 01:05 stale[bot]

@craig-rueda anything left to do? I think that the task is done, can we close?

elukey avatar May 06 '20 06:05 elukey

Hi, thanks for your contributions in order to clarify this issue, I have included my .pem certificate as part of the requests_kwargs': {'verify': 'path.file.pem')}, however it returns this error, I can't find a way for fixing it :(

OpenSSL.SSL.Error: [('x509 certificate routines', 'X509_load_cert_crl_file', 'no certificate or crl found')]

thanks for any suggestion, cheers.

rherasm avatar Mar 25 '21 11:03 rherasm

This works fine for me now. You need to ensure that the cert is in .PEM format only. One way to find our the pem file which is working is you can do a curl -v https://presto-ui name this would give you a pem file in your local desktop. You can use this .PEM file to connect via superset also.

{
        "metadata_params": {},
        "engine_params": {
           "connect_args":{
              "protocol": "https",
              "requests_kwargs": {
                       "verify": "path.pem"
                }
           }
         },
        "metadata_cache_timeout": {},
        "schemas_allowed_for_csv_upload": []
    }

Hi Bharat, May I know how you solved the issue? I am also facing the same issue.

radhakvnr avatar Nov 10 '21 10:11 radhakvnr