File tree 1 file changed +12
-2
lines changed
1 file changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -405,14 +405,24 @@ async def setup_indexes(self):
405
405
)
406
406
logger .debug ("Successfully configured and verified database indexes." )
407
407
408
- async def validate_database_connection (self ):
408
+ async def validate_database_connection (self , * , ssl_retry = True ):
409
409
try :
410
410
await self .db .command ("buildinfo" )
411
411
except Exception as exc :
412
412
logger .critical ("Something went wrong while connecting to the database." )
413
413
message = f"{ type (exc ).__name__ } : { str (exc )} "
414
414
logger .critical (message )
415
-
415
+ if "CERTIFICATE_VERIFY_FAILED" in message and ssl_retry :
416
+ mongo_uri = self .bot .config ["connection_uri" ]
417
+ if mongo_uri is None :
418
+ mongo_uri = self .bot .config ["mongo_uri" ]
419
+ for _ in range (3 ):
420
+ logger .warning ("FAILED TO VERIFY SSL CERTIFICATE, ATTEMPTING TO START WITHOUT SSL (UNSAFE)." )
421
+ logger .warning ("To fix this warning, check there's no proxies blocking SSL cert verification, "
422
+ "run \" Certificate.command\" on MacOS, "
423
+ "and check certifi is up to date \" pip3 install --upgrade certifi\" ." )
424
+ self .db = AsyncIOMotorClient (mongo_uri , tlsAllowInvalidCertificates = True ).modmail_bot
425
+ return await self .validate_database_connection (ssl_retry = False )
416
426
if "ServerSelectionTimeoutError" in message :
417
427
logger .critical (
418
428
"This may have been caused by not whitelisting "
You can’t perform that action at this time.
0 commit comments