Android Flet App accessing Detabase in the cloud error message: [SSL: CERTIFICATE_VERIFY_FAILED] #2312
-
QuestionI built an android sample todo app using This setup worked in windows 10 without issues. I have three files namely: .env, requirements.txt and main.py. In my android device Samsung Galaxy A14 with latest update installed, I got this error message:
This is triggered in the following code, when I try to fetch entries in the Detabase, and is captured by the SnackBar.
Does this issue related to my device, or deta space or from the flet's built apk? Code sample.env DATA_KEY = 'XXXXXXXX' requirements.txt
main.py
------------------------------------------------------
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
Add the following code to import certifi
import os
os.environ["REQUESTS_CA_BUNDLE"] = certifi.where()
os.environ["SSL_CERT_FILE"] = certifi.where()
if os.getenv("FLET_PLATFORM") == "android":
import ssl
def create_default_context(
purpose=ssl.Purpose.SERVER_AUTH, *, cafile=None, capath=None, cadata=None
):
return ssl.create_default_context(
purpose=purpose, cafile=certifi.where(), capath=capath, cadata=cadata
)
ssl._create_default_https_context = create_default_context Hope that helps. I'm going to document that. |
Beta Was this translation helpful? Give feedback.
Add the following code to
main.py
of your Flet app to "fix" SSL issue on both iOS and Android:Hope that helps.
I'm going to document that.