-
[์ค๋ฅํด๊ฒฐ] osX + python3 + SSL certificate ErrorML engineer/Papers & CS generals 2023. 1. 7. 20:42๋ฐ์ํ
๐ 3 mins read
# SSLCertVerificationError
osX + python3.X ์์ ์ผ๋ถ ๋ชจ๋ ๋ด์์ ๋ฐ์ดํฐ๋ฅผ ๋ค์ด๋ก๋ ๋ฐ๊ฑฐ๋ ํ๋ ๊ฒฝ์ฐ์ ๊ฐ๋ ๋ณผ ์ ์๋ ์ค๋ฅ์ ๋๋ค.
SSL ์ธ์ฆ์ ์ค๋ฅ๋ฌธ์ ์ธ๋ฐ, ๋ค์๊ณผ ๊ฐ์ด python3.X ์์, ํ์ด์ฌ ๋ชจ๋๋ก ๋ฐ์ดํฐ๋ฅผ ๋ค์ด๋ก๋ ๋ฐ๋ ๊ฒฝ์ฐ์ ์ฃผ๋ก ๋ฐ์ํฉ๋๋ค.
(๋ฌผ๋ก SSL ์ธ์ฆ์๋ฅผ ์๊ตฌํ๋ ํต์ ์ด๋ผ๋ฉด ๊ผญ ๋ฐ์ดํฐ๋ฅผ ๋ค์ด ๋ฐ์๋๊ฐ ์๋์๋ ์๊ฒ ์ฃ ?)Traceback (most recent call last): File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/urllib/request.py", line 1350, in do_open encode_chunked=req.has_header('Transfer-encoding')) File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/http/client.py", line 1277, in request self._send_request(method, url, body, headers, encode_chunked) File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/http/client.py", line 1323, in _send_request self.endheaders(body, encode_chunked=encode_chunked) File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/http/client.py", line 1272, in endheaders self._send_output(message_body, encode_chunked=encode_chunked) File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/http/client.py", line 1032, in _send_output self.send(msg) File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/http/client.py", line 972, in send self.connect() File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/http/client.py", line 1447, in connect server_hostname=server_hostname) File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/ssl.py", line 423, in wrap_socket session=session File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/ssl.py", line 870, in _create self.do_handshake() File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/ssl.py", line 1139, in do_handshake self._sslobj.do_handshake() ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1091)
- ์์ ์์์ ๊ฒฝ์ฐ ๋งฅ๋ถ์์ korpora๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ก ํ๊ตญ์ด ์ฝํผ์ค๋ฅผ ๋ค์ด ๋ฐ์๋ ๋ฐ์ํ ๋ก๊ทธ์ธ๋ฐ์,
# Solution
"Finder"์์ "Applications/python3.X/Install Certificates.command" ์คํฌ๋ฆฝํธ ํ์ผ์ ์ง์ ์คํ ํด์ฃผ๊ฑฐ๋,
์๋์ bash ์คํฌ๋ฆฝํธ๋ฅผ ์คํํ๋ฉด ๋ฉ๋๋ค.
(๊ฐ์ ๋ด์ฉ์ ๋๋ค. ๋ค๋ง, python3.X์ ํด๋น ๊ฒฝ๋ก์ ๋ง๊ฒ ์์ ํ์)#!/bin/sh /Library/Frameworks/Python.framework/Versions/3.7/bin/python3.7 << "EOF" # install_certifi.py # # sample script to install or update a set of default Root Certificates # for the ssl module. Uses the certificates provided by the certifi package: # https://pypi.org/project/certifi/ import os import os.path import ssl import stat import subprocess import sys STAT_0o775 = ( stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR | stat.S_IRGRP | stat.S_IWGRP | stat.S_IXGRP | stat.S_IROTH | stat.S_IXOTH ) def main(): openssl_dir, openssl_cafile = os.path.split( ssl.get_default_verify_paths().openssl_cafile) print(" -- pip install --upgrade certifi") subprocess.check_call([sys.executable, "-E", "-s", "-m", "pip", "install", "--upgrade", "certifi"]) import certifi # change working directory to the default SSL directory os.chdir(openssl_dir) relpath_to_certifi_cafile = os.path.relpath(certifi.where()) print(" -- removing any existing file or link") try: os.remove(openssl_cafile) except FileNotFoundError: pass print(" -- creating symlink to certifi certificate bundle") os.symlink(relpath_to_certifi_cafile, openssl_cafile) print(" -- setting permissions") os.chmod(openssl_cafile, STAT_0o775) print(" -- update complete") if __name__ == '__main__': main() EOF
SSL ์ธ์ฆ์ ์ค์น ํ์ ์ฝํผ์ค ๋ค์ด๋ก๋๋ ์ ์๋ํ๋ ๋ชจ์ต์ ๋๋ค.
(korpora).venv โฏ korpora fetch --corpus korean_petitions ## Arguments of Korpora CLI ## - corpus : ['korean_petitions'] - force_download : False - func : fetch - root : None [korean_petitions] download petitions_2017-08: 1.84MB [00:00, 7.06MB/s] [korean_petitions] download petitions_2017-09: 20.4MB [00:01, 11.0MB/s] [korean_petitions] download petitions_2017-10: 12.0MB [00:00, 20.6MB/s] [korean_petitions] download petitions_2017-11: 28.4MB [00:01, 27.6MB/s] [korean_petitions] download petitions_2017-12: 29.0MB [00:00, 29.8MB/s] [korean_petitions] download petitions_2018-01: 43.9MB [00:01, 29.7MB/s] [korean_petitions] download petitions_2018-02: 33.8MB [00:01, 31.6MB/s] [korean_petitions] download petitions_2018-03: 34.3MB [00:01, 22.0MB/s] [korean_petitions] download petitions_2018-04: 35.5MB [00:01, 30.5MB/s] [korean_petitions] download petitions_2018-05: 37.5MB [00:01, 24.1MB/s] [korean_petitions] download petitions_2018-06: 37.8MB [00:01, 32.5MB/s] [korean_petitions] download petitions_2018-07: 40.5MB [00:01, 33.1MB/s] [korean_petitions] download petitions_2018-08: 39.8MB [00:01, 32.1MB/s] [korean_petitions] download petitions_2018-09: 36.1MB [00:01, 29.6MB/s] [korean_petitions] download petitions_2018-10: 38.1MB [00:01, 29.6MB/s] [korean_petitions] download petitions_2018-11: 37.7MB [00:01, 31.7MB/s] [korean_petitions] download petitions_2018-12: 33.0MB [00:00, 34.5MB/s] [korean_petitions] download petitions_2019-01: 34.8MB [00:02, 13.6MB/s] [korean_petitions] download petitions_2019-02: 30.8MB [00:01, 19.2MB/s] [korean_petitions] download petitions_2019-03: 34.9MB [00:01, 28.8MB/s]
๋ฐ์ํ'ML engineer > Papers & CS generals' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
Domain Name System (DNS) ๊ฐ์ (0) 2023.01.22 ๋ถ์ฐ ์์คํ ๋์์ธ (0) 2023.01.19 [Paper] One Embedder, Any Task: Instruction-Finetuned Text Embeddings (0) 2023.01.17 [Paper] ELMER: A Non-Autoregressive Pre-trained Language Model for Efficient and Effective Text Generation (2) 2023.01.05 Consistency Model์ ์ข ๋ฅ (0) 2023.01.02