問題描述
我一直在努力處理綁定到通過 AWS API Gateway 托管的 API 的 Kivy 應用程序中的 HTTPS 請求.首先,我從 Python3 轉到 2,然后從 requests 庫轉到 kivy 的 URLRequest.
I've been struggling with HTTPS requests in a Kivy app tied to an API hosted through AWS API Gateway. First, I moved from Python3 to 2 and then from the requests library to kivy's URLRequest.
該應用程序在我的 linux 桌面上運行良好.當我使用請求庫發出 API 請求時,出現 SSL 錯誤:SSL23_GET_SERVER_HELLO:sslv3 alert handshake failure
The app works fine on my linux desktop. When I made the API request with the requests library I got an SSL error: SSL23_GET_SERVER_HELLO:sslv3 alert handshake failure
我轉而使用 URLRequest,它似乎與 requests 有相同的 SSL 錯誤.傳遞給 URLRequest 錯誤回調的參數是:(, SSLError(1, '_ssl.c:503: error:14077410:SSLroutines:SSL23_GET_SERVER_HELLO:sslv3 alert handshake failure')))
I moved to using URLRequest, which seems to be having the same SSL error as requests was. Arguments passed into the URLRequest error callback are: (, SSLError(1, '_ssl.c:503: error:14077410:SSL routines:SSL23_GET_SERVER_HELLO:sslv3 alert handshake failure'))
我發現了這個 stackoverflow 問題:SSL23_GET_SERVER_HELLO:sslv3 警報握手失敗 [基維]
I found this stackoverflow question: SSL23_GET_SERVER_HELLO:sslv3 alert handshake failure [Kivy]
這意味著這與過時的 python 版本有關.
Which implies this has to do with outdated python versions.
只是 Kivy android 應用無法與 AWS API 網關通信嗎?
Is it just a Kivy android app is incapable of communicating with an AWS API Gateway?
Buildozer .spec 行:要求 = hostpython2、kivy、future、python-dateutil、openssl、pyopenssl、jmespath、botocore、boto3、requests
Buildozer .spec lines: requirements = hostpython2, kivy, future, python-dateutil, openssl, pyopenssl, jmespath, botocore, boto3, requests
android.permissions = 互聯網
android.permissions = INTERNET
更新:我使用 URL https://kivy 測試了一個 HTTPS GET 請求.org/logos/kivy-logo-black-64.png.這在 Android 應用程序中成功完成.這個問題似乎特定于 AWS API Gateway 使用的 SSL 版本
UPDATE: I tested a HTTPS GET request with the URL https://kivy.org/logos/kivy-logo-black-64.png. This completed successfully in the Android App. This problem seems to be specific to the SSL version used by AWS API Gateway
UPDATE2:Android 上的 Kivy 也可以與 Google Cloud Platform 的云功能 HTTPS 端點一起正常工作.更多證據表明此問題與 AWS API Gateway 密切相關.
UPDATE2: Kivy on Android also works fine with Google Cloud Platform's cloud functions HTTPS endpoints. Even more evidence this issue is specifically tied to AWS API Gateway.
推薦答案
確保您的 .spec 文件具有 Internet 權限.另外,如果您使用 python2,我相信您的要求中需要hostpython2".我不確定您在其中的任何要求是否依賴于 python 2 或 3,但如果您使用的是 python 2,請確保它們適用于 python 2.此外,我認為您的請求要求中不需要 [安全].嘗試只輸入請求",您也可以嘗試安裝 sqlite 并將 g 添加到您的要求中.
Make sure your .spec file has internet permissions. Also I believe you need 'hostpython2' in your requirements if you are using python2. Im not sure if any of the requirements you have in there are python 2 or 3 dependent but make sure they work for python 2 if that's what your using. Also I dont think you need the [security] in your requests requirement. Try just putting 'requests' also u might try installing sqlite and adding g that into your requirements as well.
這篇關于Kivy 中的 HTTPS 請求的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!