python
몽고디비와 파이썬이 SSL 문제로 연결이 안될 때. import certifi
eastjin
2023. 7. 19. 14:48
반응형
스파르타코딩클럽 커뮤니티 | 스파르타코딩클럽 수강생이라면 누구나
나만 놓칠 수 없는 이야기들이 가득한 자유게시판, 코딩하다 막히면 바로 질문하는 즉문즉답, 개발일지 모음까지
spartacodingclub.kr
from pymongo.mongo_client import MongoClient
import certifi
ca = certifi.where()
client = MongoClient("mongodb+srv://<id>:<password>@cluster0.nb3pybc.mongodb.net/?retryWrites=true&w=majority", tlsCAFile=ca)
# Send a ping to confirm a successful connection
try:
client.admin.command('ping')
print("Pinged your deployment. You successfully connected to MongoDB!")
except Exception as e:
print(e)
<id>랑 <password>는 본인들 것 쓰삼.
certifi는 모질라 루트 인증서 모음인데 이것을 쓰고 client 끝에 tlsCAFile=ca를 해주면 정상 연결이 된다.
그다음 몽고디비에서 제공한 소스를 적용해보니 정상 확인 되었다.
SSL은 그럼 뭐냐.
728x90