時刻設定が原因で SSL エラー



旧い RaspberryPi 環境で操作しようとしたらエラーが出た。

```

$ sudo pip3 install nfcpy
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Collecting nfcpy
  Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLError("bad handshake: Error([('SSL routines', 'tls_process_server_certificate', 'certificate verify failed')])"))': /simple/nfcpy
/
  Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLError("bad handshake: Error([('SSL routines', 'tls_process_server_certificate', 'certificate verify failed')])"))': /simple/nfcpy
/
.
.
.

```

# 環境

- Raspberry Pi 3 Model B Rev 1.2r
- raspbian_lite-2020-02-14

# 様々なエラー

```

# sudo pip3 install nfcpy
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Collecting nfcpy
  Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLError(ess_server_certificate', 'certificate verify failed')])"))': /simple/nfcpy/
  Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLError(ess_server_certificate', 'certificate verify failed')])"))': /simple/nfcpy/
  Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLError(ess_server_certificate', 'certificate verify failed')])"))': /simple/nfcpy/
.
.
.
  Could not find a version that satisfies the requirement nfcpy (from versions: )
No matching distribution found for nfcpy

```

curl とかもエラー。

```

# curl -v https://acme-v02.api.letsencrypt.org/directory
* Expire in 0 ms for 6 (transfer 0xf07880)
* Expire in 1 ms for 1 (transfer 0xf07880)
* Expire in 0 ms for 1 (transfer 0xf07880)
* Expire in 1 ms for 1 (transfer 0xf07880)
.
.
.
*   Trying 172.65.32.248...
* TCP_NODELAY set
* Expire in 149972 ms for 3 (transfer 0xf07880)
* Expire in 200 ms for 4 (transfer 0xf07880)
* Connected to acme-v02.api.letsencrypt.org (172.65.32.248) port 443 (#0)
* ALPN, offering h2
* ALPN, offering http/1.1
* successfully set certificate verify locations:
*   CAfile: none
  CApath: /etc/ssl/certs
* TLSv1.3 (OUT), TLS handshake, Client hello (1):
* TLSv1.3 (IN), TLS handshake, Server hello (2):
* TLSv1.3 (IN), TLS handshake, Encrypted Extensions (8):
* TLSv1.3 (IN), TLS handshake, Certificate (11):
* TLSv1.3 (OUT), TLS alert, bad certificate (554):
* SSL certificate problem: certificate is not yet valid
* Closing connection 0
curl: (60) SSL certificate problem: certificate is not yet valid
More details here: https://curl.haxx.se/docs/sslcerts.html

curl failed to verify the legitimacy of the server and therefore could not
establish a secure connection to it. To learn more about this situation and
how to fix it, please visit the web page mentioned above.
```


# 原因

時刻がずれてました。

```


$ date
Tue 27 Oct 14:43:01 JST 2020
$ sudo  date 031819432022
Fri 18 Mar 19:43:00 JST 2022


```


直すと正常に動作しました。

```

$ sudo pip3 install nfcpy
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Collecting nfcpy
  Downloading https://files.pythonhosted.org/packages/96/2e/4fd1d12de425b26e0c5e74bb109cc7f55cdaf275b8f1a72e737ef584cf8a/nfcpy-1.0.4-py3-none-any.whl (186kB)
    100% |████████████████████████████████| 194kB 1.2MB/s 
Collecting pydes (from nfcpy)
  Downloading https://www.piwheels.org/simple/pydes/pyDes-2.0.1-py2.py3-none-any.whl
Requirement already satisfied: pyserial in /usr/lib/python3/dist-packages (from nfcpy) (3.4)
Collecting ndeflib (from nfcpy)
  Downloading https://files.pythonhosted.org/packages/c9/80/bbc9a4818cd74807f914d225611cd724d8c0e56237b952a9a4aa6d583f5c/ndeflib-0.3.3-py2.py3-none-any.whl (56kB)
    100% |████████████████████████████████| 61kB 2.0MB/s 
Collecting libusb1 (from nfcpy)
  Downloading https://files.pythonhosted.org/packages/e0/a0/bfe18a27c5c8e8922bdd7f1ac67c10da907b95c00c3baa92e0dd463d02b6/libusb1-3.0.0-py3-none-any.whl (62kB)
    100% |████████████████████████████████| 71kB 2.1MB/s 
Installing collected packages: pydes, ndeflib, libusb1, nfcpy
Successfully installed libusb1-3.0.0 ndeflib-0.3.3 nfcpy-1.0.4 pydes-2.0.1

```