requests.get()에서 SSL 인증서 오류
10556
작성한 질문수 3
안녕하세요.
아래와 같은 오류가 나서 구글링으로 다음과 같이 수정하여 진행을 하였습니다.
r = requests.get(url, verify=False) # verify 옵션 추가
진행은 되는데 `try`구문으로 감싸지 않으면 아래와 같은 warning이 나옵니다.
lib\site-packages\urllib3\connectionpool.py:851: InsecureRequestWarning: Unverified HTTPS request is being made. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings
InsecureRequestWarning)
혹시 컴퓨터 환경문제를 확인해 봐야 할지, 아니면 위 warning까지 없앨 수 있는 다른 방법이 있을까요?
(혹시 회사망에서 실행한게 영향이 있을지요)
# 오류 출력
Traceback (most recent call last):
...
OpenSSL.SSL.Error: [('SSL routines', 'tls_process_server_certificate', 'certificate verify failed')]
During handling of the above exception, another exception occurred:
ssl.SSLError: ("bad handshake: Error([('SSL routines', 'tls_process_server_certificate', 'certificate verify failed')])",)
...
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='ac.dict.naver.com', port=443): Max retries exceeded with url: /enendict/ac?q=test&q_enc=utf-8&st=11001 (Caused by SSLError(SSLError("bad handshake: Error([('SSL routines', 'tls_process_server_certificate', 'certificate verify failed')])")))
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "d:\Z\Python_--\10.크롤링\5_english_quiz.py", line 35, in <module>
print(test("test", URL1=True))
File "d:\Z\Python_--\10.크롤링\5_english_quiz.py", line 23, in test
r = requests.get(url)
...
requests.exceptions.SSLError: HTTPSConnectionPool(host='ac.dict.naver.com', port=443): Max retries exceeded with url: /enendict/ac?q=test&q_enc=utf-8&st=11001 (Caused by SSLError(SSLError("bad handshake: Error([('SSL routines', 'tls_process_server_certificate', 'certificate verify failed')])")))
답변 1
0
워닝은 그냥 경고의 표시이므로 신경 안쓰셔도 됩니다만 꼭 워닝을 없애고 싶으시다면 아래의 코드를 작성하시면 됩니다.
requests.packages.urllib3.disable_warnings(requests.packages.urllib3.exceptions.InsecureRequestWarning)
38강 = 연산자 더하고 빼기
0
59
2
주석처리
0
116
1
함수의 파라미터값 msg
0
154
1
강의자료 이미지 안나옴
0
238
3
강의자료 질문 두번째
0
164
3
강의자료 관련 질문
0
115
1
파이썬 예외 처리 try / except 파일 처리 코드가 실행이 안됩니다.
0
234
1
소수 너무 어려워요
0
244
1
imagefont 함수 사용
0
238
1
pylint
0
355
1
add 함수 문의 ㅠㅠ
0
280
1
형식 문의드립니다.
0
208
1
변수 명을 왜 src, tar로 하셨는지 궁금합니다.
0
601
1
숫자야구 코드를 짜 봤는데 뭔가 이상합니다.
0
249
1
zsh: command not found: pylint
0
268
1
텔레그램 봇 만들기 코드 실행이 안됩니다 박사님..ㅠ
0
545
1
질문드립니다.
1
373
2
list.reverse() 출력에 대해서 질문있습니다.
1
431
1
데코레이터 함수 및 동작시간 질문입니다.~
1
322
2
opencv 사용하면서 궁금한점 (해상도)
1
780
1
질문드립니다.
1
298
1
아래 오류가 뜨면서 vscode가 컴파일이 되지 않는데.. 혹시 왜이럴까요?
1
444
1
크롤링안되는 현상 문의 드립니다.
1
420
1
파이썬 크롤링 관련 문의
1
276
1





