Skip to content

Builds break after adding SNI for API HTTPS endpoint #4494

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

Closed
humitos opened this issue Aug 8, 2018 · 1 comment
Closed

Builds break after adding SNI for API HTTPS endpoint #4494

humitos opened this issue Aug 8, 2018 · 1 comment
Assignees
Labels
Accepted Accepted issue on our roadmap Bug A bug

Comments

@humitos
Copy link
Member

humitos commented Aug 8, 2018

#4423 introduced a bug when trying to access the API from the builder.

This is needed for our Azure migration, so we need to find a way to make it work. This is currently working under our Azure servers.

Traceback (most recent call last):
  File "/home/humitos/rtfd/code/readthedocs.org/readthedocs/projects/tasks.py", line 333, in run
    self.project = self.get_project(pk)
  File "/home/humitos/rtfd/code/readthedocs.org/readthedocs/projects/tasks.py", line 512, in get_project
    project_data = api_v2.project(project_pk).get()
  File "/home/humitos/.pyenv/versions/3.6.6/envs/readthedocs.org/lib/python3.6/site-packages/slumber/__init__.py", line 155, in get
    resp = self._request("GET", params=kwargs)
  File "/home/humitos/.pyenv/versions/3.6.6/envs/readthedocs.org/lib/python3.6/site-packages/slumber/__init__.py", line 97, in _request
    resp = self._store["session"].request(method, url, data=data, params=params, files=files, headers=headers)
  File "/home/humitos/.pyenv/versions/3.6.6/envs/readthedocs.org/lib/python3.6/site-packages/requests/sessions.py", line 512, in request
    resp = self.send(prep, **send_kwargs)
  File "/home/humitos/.pyenv/versions/3.6.6/envs/readthedocs.org/lib/python3.6/site-packages/requests/sessions.py", line 622, in send
    r = adapter.send(request, **kwargs)
  File "/home/humitos/.pyenv/versions/3.6.6/envs/readthedocs.org/lib/python3.6/site-packages/requests_toolbelt/adapters/host_header_ssl.py", line 43, in send
    return super(HostHeaderSSLAdapter, self).send(request, **kwargs)
  File "/home/humitos/.pyenv/versions/3.6.6/envs/readthedocs.org/lib/python3.6/site-packages/requests/adapters.py", line 445, in send
    timeout=timeout
  File "/home/humitos/.pyenv/versions/3.6.6/envs/readthedocs.org/lib/python3.6/site-packages/urllib3/connectionpool.py", line 589, in urlopen
    conn = self._get_conn(timeout=pool_timeout)
  File "/home/humitos/.pyenv/versions/3.6.6/envs/readthedocs.org/lib/python3.6/site-packages/urllib3/connectionpool.py", line 251, in _get_conn
    return conn or self._new_conn()
  File "/home/humitos/.pyenv/versions/3.6.6/envs/readthedocs.org/lib/python3.6/site-packages/urllib3/connectionpool.py", line 212, in _new_conn
    strict=self.strict, **self.conn_kw)
  File "/home/humitos/.pyenv/versions/3.6.6/envs/readthedocs.org/lib/python3.6/site-packages/urllib3/connection.py", line 125, in __init__
    _HTTPConnection.__init__(self, *args, **kw)
TypeError: __init__() got an unexpected keyword argument 'assert_hostname'

I need to research a little more to understand why this is not working locally but it is on Azure VM.

@humitos humitos added Bug A bug Accepted Accepted issue on our roadmap labels Aug 8, 2018
@humitos humitos added this to the Azure migration milestone Aug 8, 2018
@humitos humitos self-assigned this Aug 8, 2018
@humitos
Copy link
Member Author

humitos commented Aug 8, 2018

The important code regarding the assert_hostname is at

https://github.com/requests/toolbelt/blob/master/requests_toolbelt/adapters/host_header_ssl.py#L37-L41

I put a log in my instance and I see that host_header is localhost:8000, which comes from PRODUCTION_DOMAIN

https://github.com/rtfd/readthedocs.org/blob/7511411e508b32022c2568e216c020b2a793494a/readthedocs/restapi/client.py#L46

So, "maybe" in Azure production this is not failing because it is not entering in that if, and it's removing the assert_hostname kwargs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Accepted Accepted issue on our roadmap Bug A bug
Projects
None yet
Development

No branches or pull requests

1 participant