Skip to content

Connection fails with TSC 0.19.0 and SSL disabled (verify=False) #1088

Closed

Description

@devholland

Describe the bug
Connecting to Tableau Server with disabled SSL (verify=False) fails after updating from 0.18.0 to 0.19.0.

Versions
Details of your environment, including:

  • Tableau Server Version: 2022.1.3 (20221.22.0616.1738)
  • Python 3.10
  • TSC 0.19.0

To Reproduce
This code works with 0.18.0 and fails with the new 0.19.0 release:

import tableauserverclient as TSC
server = TSC.Server('https://<our.tableau.server>')
server.version = "3.3"
server.add_http_options({'verify': False})
server_auth = TSC.TableauAuth('<user>', '<password>', '<site>')
with server.auth.sign_in(server_auth):
    server_projects, _ = server.projects.get()
    print(server_projects)

Results

Traceback (most recent call last):
  File "/usr/local/lib/python3.10/site-packages/urllib3/connectionpool.py", line 703, in urlopen
    httplib_response = self._make_request(
  File "/usr/local/lib/python3.10/site-packages/urllib3/connectionpool.py", line 386, in _make_request
    self._validate_conn(conn)
  File "/usr/local/lib/python3.10/site-packages/urllib3/connectionpool.py", line 1042, in _validate_conn
    conn.connect()
  File "/usr/local/lib/python3.10/site-packages/urllib3/connection.py", line 414, in connect
    self.sock = ssl_wrap_socket(
  File "/usr/local/lib/python3.10/site-packages/urllib3/util/ssl_.py", line 449, in ssl_wrap_socket
    ssl_sock = _ssl_wrap_socket_impl(
  File "/usr/local/lib/python3.10/site-packages/urllib3/util/ssl_.py", line 493, in _ssl_wrap_socket_impl
    return ssl_context.wrap_socket(sock, server_hostname=server_hostname)
  File "/usr/local/lib/python3.10/ssl.py", line 513, in wrap_socket
    return self.sslsocket_class._create(
  File "/usr/local/lib/python3.10/ssl.py", line 1071, in _create
    self.do_handshake()
  File "/usr/local/lib/python3.10/ssl.py", line 1342, in do_handshake
    self._sslobj.do_handshake()
ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:997)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.10/site-packages/requests/adapters.py", line 489, in send
    resp = conn.urlopen(
  File "/usr/local/lib/python3.10/site-packages/urllib3/connectionpool.py", line 787, in urlopen
    retries = retries.increment(
  File "/usr/local/lib/python3.10/site-packages/urllib3/util/retry.py", line 592, in increment
    raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='<our.tableau.server)', port=443): Max retries exceeded with url: /api/2.4/serverInfo (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:997)')))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/data/__workspace/tableau.py", line 2, in <module>
    server = TSC.Server('https://<our.tableau.server>')
  File "/usr/local/lib/python3.10/site-packages/tableauserverclient/server/server.py", line 97, in __init__
    self.use_server_version()
  File "/usr/local/lib/python3.10/site-packages/tableauserverclient/server/server.py", line 139, in use_server_version
    self.version = self._determine_highest_version()
  File "/usr/local/lib/python3.10/site-packages/tableauserverclient/server/server.py", line 129, in _determine_highest_version
    version = self.server_info.get().rest_api_version
  File "/usr/local/lib/python3.10/site-packages/tableauserverclient/server/endpoint/endpoint.py", line 186, in wrapper
    return func(self, *args, **kwargs)
  File "/usr/local/lib/python3.10/site-packages/tableauserverclient/server/endpoint/server_info_endpoint.py", line 23, in get
    server_response = self.get_unauthenticated_request(self.baseurl)
  File "/usr/local/lib/python3.10/site-packages/tableauserverclient/server/endpoint/endpoint.py", line 109, in get_unauthenticated_request
    return self._make_request(self.parent_srv.session.get, url)
  File "/usr/local/lib/python3.10/site-packages/tableauserverclient/server/endpoint/endpoint.py", line 65, in _make_request
    server_response = method(url, **parameters)
  File "/usr/local/lib/python3.10/site-packages/requests/sessions.py", line 600, in get
    return self.request("GET", url, **kwargs)
  File "/usr/local/lib/python3.10/site-packages/requests/sessions.py", line 587, in request
    resp = self.send(prep, **send_kwargs)
  File "/usr/local/lib/python3.10/site-packages/requests/sessions.py", line 701, in send
    r = adapter.send(request, **kwargs)
  File "/usr/local/lib/python3.10/site-packages/requests/adapters.py", line 563, in send
    raise SSLError(e, request=request)
requests.exceptions.SSLError: HTTPSConnectionPool(host='<our.tableau.server>', port=443): Max retries exceeded with url: /api/2.4/serverInfo (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:997)')))

Activity

  1. bcantoni commented on Aug 8, 2022

    @bcantoni
    Contributor

    This was a result of changing the default behavior for use_server_version - it's been fixed in the development branch in #1081.

    Until that change makes it to a release, I believe you can work around the problem by explicitly setting use_server_version to false in your initialization:

    server = TSC.Server('https://<our.tableau.server>', use_server_version=False)
    
  2. devholland commented on Aug 9, 2022

    @devholland
    Author

    Thank you, that fixed the bug for us.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions