문제
pymongo.errors.ServerSelectionTimeoutError: cluster0-shard-00-00.4bw3y.mongodb.net:27017: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get issuer certificate (_ssl.c:997),cluster0-shard-00-01.4bw3y.mongodb.net:27017: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get issuer certificate (_ssl.c:997),cluster0-shard-00-02.4bw3y.mongodb.net:27017: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get issuer certificate (_ssl.c:997), Timeout: 30s, Topology Description: <TopologyDescription id: 62997a0dfe47f2fad0f27ecb, topology_type: ReplicaSetNoPrimary, servers: [<ServerDescription ('cluster0-shard-00-00.4bw3y.mongodb.net', 27017) server_type: Unknown, rtt: None, error=AutoReconnect('cluster0-shard-00-00.4bw3y.mongodb.net:27017: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get issuer certificate (_ssl.c:997)')>, <ServerDescription ('cluster0-shard-00-01.4bw3y.mongodb.net', 27017) server_type: Unknown, rtt: None, error=AutoReconnect('cluster0-shard-00-01.4bw3y.mongodb.net:27017: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get issuer certificate (_ssl.c:997)')>, <ServerDescription ('cluster0-shard-00-02.4bw3y.mongodb.net', 27017) server_type: Unknown, rtt: None, error=AutoReconnect('cluster0-shard-00-02.4bw3y.mongodb.net:27017: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get issuer certificate (_ssl.c:997)')>]>
- mongoDB atlas를 테스트하던 중 에러 발생
- python code로 atlas에 접근하려 했으나 해당 에러 발생으로 접근이 불가했다.
해결
- 라이브러리 설치
pip install certifi
- certifi 임포트
- MongoClient() 인자로 tlsCAFile=certifi.where() 할당
from pymongo import MongoClient
import certifi
client = MongoClient('mongodb+srv://admin:admin@cluster0.4bw3y.mongodb.net/?retryWrites=true&w=majority', tlsCAFile=certifi.where())
출처
'CS > DB' 카테고리의 다른 글
[데이터베이스] 트랜잭션 격리 수준(Transaction Isolation Level) (0) | 2023.07.18 |
---|---|
[데이터베이스] 파티셔닝 (0) | 2023.07.18 |
[데이터베이스] Database Connection Pool, DBCP (0) | 2023.07.04 |
mysql 1205 Lock wait timeout exceeded; try restarting transaction (0) | 2022.05.25 |
mysql foreign key 적용된 테이블의 레코드 삭제하기 (0) | 2022.05.25 |