8000 [DCOS_OSS-618] Ignore core.ssl_verify for external requests by bamarni · Pull Request #1028 · dcos/dcos-cli · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

[DCOS_OSS-618] Ignore core.ssl_verify for external requests #1028

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

Merged
merged 1 commit into from
Aug 23, 2017

Conversation

bamarni
Copy link
Contributor
@bamarni bamarni commented Aug 8, 2017

Otherwise, when a cluster is configured with a custom CA path, it will
try to use it instead of the system's CA bundle and external requests
will fail.

In such cases, setting it to None will let the requests package enabling
it by default.

dcos/http.py Outdated
8000
@@ -190,6 +210,7 @@ def _request_match(expected_url, actual_url):
if is_success(response.status_code):
return response
elif response.status_code == 401:
prompt_login = config.get_config_val("core.prompt_login", toml_config)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change seems unrelated. It should either be a second commit in this pull request with a detailed commit message describing its purpose, or a separate PR.

dcos/http.py Outdated
@@ -27,6 +27,34 @@ def _default_is_success(status_code):

return 200 <= status_code < 300

def _is_request_to_cluster(url, toml_config=None):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we call this _is_request_to_dcos() instead?

@klueska
Copy link
Contributor
klueska commented Aug 9, 2017

Also, we need to add an integration test before we can call this done.

@bamarni
Copy link
Contributor Author
bamarni commented Aug 10, 2017

I've just pushed a commit according to your comments.

What kind of integration test are you thinking of? As it involves an HTTPS request to an external URL I don't see an obvious way to do it.

toml_config = config.get_config()

dcos_url = urlparse(config.get_config_val("core.dcos_url", toml_config))
cosmos_url = urlparse(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is cosmos_url? And what happens if it's not set in the toml file (as far as I know, it's usually not set).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also don't have it set, in that case it is ignored, urlparse will return an empty ParseResult and this won't be matched.

dcos/http.py Outdated
request_to_cluster = _request_match(dcos_url, parsed_url) or \
_request_match(cosmos_url, parsed_url)

return request_to_cluster
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can probably just return the or statement directly without assigning to an intermediate variable? Otherwise, you should rename this variable to something like is_request_to_dcos. Up to you.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll set it as is_request_to_dcos for readability.

dcos/http.py Outdated
verify = _verify_ssl(verify, toml_config)
else:
# Ignore core.ssl_verify if request is outside the DC/OS cluster (DCOS_OSS-618)
verify = None
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of doing an if/else here, I would just do:

if verify and _is_request_to_dcos(url, toml_config):
    verify = _verify_ssl(verify, toml_config)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here verify can be a path, and even though I coulnd't see it in the codebase, my concern was if this function gets called with an explicit custom CA path for the cluster and an external https url. In such cases I wanted to force verify to None.

@bamarni bamarni force-pushed the dcos-oss-618 branch 2 times, most recently from c634cce to dd597fa Compare August 18, 2017 10:18
Otherwise, when a cluster is configured with a custom CA path, it will
try to use it instead of the system's CA bundle and external requests
will fail.

In such cases, setting it to None will let the requests package enabling
it by default.
@klueska klueska merged commit d257d4d into dcos:master Aug 23, 2017
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

Successfully merging this pull request may close these issues.

2 participants
0