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 issues with Leap_Second.dat source #317

Closed
rtphokie opened this issue Jan 5, 2020 · 9 comments
Closed

SSL issues with Leap_Second.dat source #317

rtphokie opened this issue Jan 5, 2020 · 9 comments

Comments

@rtphokie
Copy link

rtphokie commented Jan 5, 2020

Python Version: 3.7.3
OS: Mac OS Catalina version 10.15.2
SkyField version: 1.16

The automation which which attempts to fetch leap second information from the International Earth rotation and Reference Systems Service is running into certificate problems. Note this only happens when the Leap_Second.dat file is not cached locally.

OSError: cannot get https://hpiers.obspm.fr/iers/bul/bulc/Leap_Second.dat because <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1056)>

The problem is not with the Paris Observatory website but in Python 3.7 specifically with how urlib2.urlopen() accesses some https sites. For what it is worth, requests.get() fetches this URL (https://hpiers.obspm.fr/iers/bul/bulc/Leap_Second.dat) without any problem.

A workaround is to manually fetch the file and save it locally.

@brandon-rhodes
Copy link
Member

Thanks for letting me know! Do other Python versions work, break, or is 3.7 the only one you've been able to test so far?

@Mausy5043
Copy link

I have the same issue with Python 3.6.6 on macOS.

No problems with Python 3.7.3 on Debian buster.

@Mausy5043
Copy link

Mausy5043 commented Jan 25, 2020

Haven't fully digested it yet, but I feel this may contain a hint of the cause: link.

EDIT: However, this question on StackOverflow : https://stackoverflow.com/questions/27835619/urllib-and-ssl-certificate-verify-failed-error

Has an answer from user Craig Glennie that might point at the culprit. It suggests that Python 3.6 on macOS comes with no SSL certificates whatsoever.

The fixed suggested there worked for me:

/Applications/Python\ 3.6/Install\ Certificates.command

@brandon-rhodes
Copy link
Member

So a missing SSL certificate might be at issue? Interesting. Which raises many of the points brought up here:

https://stackoverflow.com/questions/22027418/openssl-python-requests-error-certificate-verify-failed

@rtphokie — Does the certificate install command fix the situation for you as well? If so then I'll not only add a note to the documentation, but could add a try-except to the Skyfield code so that it prints out a suggestion about running that command if it encounters the error in front of the user!

@richf27
Copy link

richf27 commented Apr 20, 2020

Good day. For those of us who are new to python and are experiencing the same SSL issue retrieving this file, what directory should I download this file to? Thanks!

@brandon-rhodes
Copy link
Member

@richf27 Try load.timescale(builtin=True), if you aren't worried about leap-second-level accuracy in the future — would that get your script working again?

Also: you simply download files to the current directly unless you've created a loader that uses some other directly. Where in the docs could I make that clearer so that users know where to put the file? Can you point me at which docs you were following when you ran into the problem? Thanks!

brandon-rhodes added a commit that referenced this issue Apr 22, 2020
Should help users in a situation like #317, where it was the leap
second file that gave someone a problem, rather than the more usual ΔT
culprits.
brandon-rhodes added a commit that referenced this issue Apr 22, 2020
Though I am loathe to introduce yet another dependency to Skyfield,
issue #317 would seem to require it unless I want to guide users through
updating their system certificates themselves, or want to introduce yet
more options and variations in the download routines.  Alas that it
incurs 308k of disk, which most users will never benefit from since
their system certificates were working fine!  But the simplicity of
giving all users the same experience seems at this point preferable.
And the extra disk space is just 1/200th of the cost of NumPy, right?
@brandon-rhodes
Copy link
Member

I've just released Skyfield 1.19 which, by moving to the certifi set of certificates instead of relying on the operating system's certs found by Python itself, hopefully resolves this issue. I'll close it for now, but please comment further if you still have problems!

@dearchap
Copy link

dearchap commented Nov 8, 2023

I still get this error with 1.46.

Traceback (most recent call last):
  File "./main.py", line 10, in <module>
    planets = load('de421.bsp')
  File "/home/deployuser/p3orb/lib/python3.8/site-packages/skyfield/iokit.py", line 193, in __call__
    path = self._assure(url, filename, reload, backup)
  File "/home/deployuser/p3orb/lib/python3.8/site-packages/skyfield/iokit.py", line 214, in _assure
    download(url, path, self.verbose, backup=backup)
  File "/home/deployuser/p3orb/lib/python3.8/site-packages/skyfield/iokit.py", line 525, in download
    raise e2
OSError: cannot download https://ssd.jpl.nasa.gov/ftp/eph/planets/bsp/de421.bsp because <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1131)>

@brandon-rhodes
Copy link
Member

@dearchap — Alas, Skyfield isn't directly involved in the SSL computation, so you will need to look up the error message and probably your operating system documentation to learn about why Python on your computer can't make the connection. My advice would be to download the file yourself, so that Skyfield is not involved and you can talk to the Internet directly from your script. I would start by seeing if you can download that URL in your browser, without Python at first being involved.

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

No branches or pull requests

5 participants