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

SSL Error with Certificate in catalog.py #281

Open
eroesler opened this issue Sep 19, 2019 · 4 comments · May be fixed by #303
Open

SSL Error with Certificate in catalog.py #281

eroesler opened this issue Sep 19, 2019 · 4 comments · May be fixed by #303

Comments

@eroesler
Copy link

Please redirect or absolve the issue if it violates the contributing guidelines

I've been working to get a tutorial python code from the Unidata site called GOES_aircraft.py, working from my corporation's computer. In the script, there are two function calls to retrieve data. When I execute this script, it fails with SSL errors related to the certificate verify failing. (note: This looks like a common problem for people running python scripts behind corporate firewalls.)

I've managed to figure-out a work-around for the first function, 'get_plane_data' by adding / altering these two lines:
.....
context = ssl._create_unverified_context()
with urllib.request.urlopen(endpoint_url, context=context) as f:
.....

When it comes to the second function, however, 'get_goes_image', I am not sure how to bypass the certificate check in the TDSCatalog call. I've looked through the catalog.py script for a flag for a solution, but am unable to identify where to begin.

Help or advice is greatly appreciated.

@dopplershift
Copy link
Member

I appreciate the report. Does this answer on Stack Overflow help? I think it should work if you pass verify=False to set_session_options. Even better, you should be able to then use:

with siphon.http_util.session_manager.urlopen(endpoint_url) as f:
...

Using functions that start with _ from a library (like _create_unverfied_context) is kind of a no-no, as they're not guaranteed to exist in future versions.

@eroesler
Copy link
Author

eroesler commented Oct 2, 2019

@dopplershift : Thank you for the response. Here's what's happening after trying some StackOverFlow

I've added to the top:

 from siphon.http_util import session_manager

commented-out in get_plane_data,

 #with urllib.request.urlopen(endpoint_url) as f:

and replaced it with

session_manager.set_session_options(verify=False)      
with siphon.http_util.session_manager.urlopen(endpoint_url) as f:

I think I'm missing something because this now thows an error:

with siphon.http_util.session_manager.urlopen(endpoint_url) as f:
NameError: name 'siphon' is not defined

Even though using _create_unverfied_context is naughty, I did get the get_plane_data function to work.

The function, get_goes_image, is still failing. I am not sure how to correct this yet still. I've tried adding the recommended commands to the more simple example, Basic_Usage.py, and still get the proxy errors.

@dopplershift
Copy link
Member

What you have is not quite valid use of Python imports. You can either do:

from siphon.http_util import session_manager
...
with session_manager.urlopen(endpoint_url) as f:

OR

import siphon.http_util
...
with siphon.http_util.session_manager.urlopen(endpoint_url) as f:

(The ... are not literal but represent elided code.)

@kahemker kahemker linked a pull request Feb 28, 2020 that will close this issue
3 tasks
@kahemker
Copy link

I have a similar problem while working on my corporate network. The only solution that I have found is with any HTTP GET request, I must pass specific set of headers and turn off SSL verify. When I am just performing a simple request with the requests module directly, I can set these options to whatever I need. However, I have found siphon quite useful for acquiring MET data, so I did a little digging through the source and found an easy way to also pass the same arguments through here.

Check out this PR to see which lines I modified. #303

Exactly which settings you need to get this working on your proxy are probably different than mine, but hopefully this minor code change to siphon will allow you to get running at work.

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

Successfully merging a pull request may close this issue.

3 participants