Kivy 中的 HTTPS 请求 [英] HTTPS Request in Kivy

查看:22
本文介绍了Kivy 中的 HTTPS 请求的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在努力处理绑定到通过 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 请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆