如果仅被Android应用程序消耗,则可以在没有HTTPS和JWT的情况下开发REST API?
我计划用 JAVA 和 Spring Boot 创建一个后端应用程序,它有一组 REST API。如果这些 API 由单个 Android 应用程序使用,那么我是否需要使用 HTTPS (SSL/TLS)、JWT 令牌等来保护它们。
I am planning to create an back end application in JAVA and Spring Boot which has a set of REST APIs. If these APIs are consumed by a single Android application then do I need to secure them using HTTPS (SSL/TLS), JWT token etc.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
APIS 中应该使用 HTTPS 吗?
。绝对是的。
现在没有理由不使用 HTTPS,我在我的文章中讨论了为什么应该使用 HTTPS 六大移动 API 保护技术 - 它们足够了吗?:
HTTPS 足以保护 API 的安全吗?
不可以,因为存在许多逆向工程技术和工具来绕过 HTTPS 在移动应用程序和 API 服务器之间提供的安全通信通道。
一种非常流行的技术是部署中间人 (MitM) 攻击,这将允许攻击者解密他控制的设备中的 HTTPS 流量或诱导用户安装自定义证书,但这可以通过以下方式来阻止:使用证书固定。
您可以在我的文章 通过中间人攻击窃取 Api 密钥:
使用证书固定保护 HTTPS
要防止发生 MitM 攻击,您可以在移动应用程序上部署证书固定,您可以在我的文章中了解更多信息 使用证书固定保护 HTTPS:
本文将向您展示如何使用移动证书固定生成器,这是一个在线免费工具,可以让您准备好使用 Android 和 iOS 的配置文件并配置固定。
只需添加要固定的 API 域:
然后将配置复制并粘贴到您的 Android 应用程序中:
请阅读工具常见问题解答,了解使用静态证书固定的利弊和陷阱 选项卡:
您想加倍努力吗?
在回答安全问题时,我总是喜欢参考 OWASP 基金会的出色工作。
对于 APIS
OWASP API 安全性前 10 名
对于移动应用
OWASP 移动安全项目 - 十大风险
OWASP - 移动安全测试指南:
Should HTTPS be Used in APIS?
Absolutely Yes.
No reason exists nowadays for not using HTTPS and I talk about why you should use HTTPS in my article The Top 6 Mobile API Protection Techniques - Are They Enough?:
Is HTTPS enough to secure the API?
No, because a lot of reverse engineer techniques and tools exist to byapss the secure communication channel that HTTPS provides between the mobile app and the API server.
A very popular technique is to deploy a Man in the Middle (MitM) attack, that will allow for an attacker to decrypt the HTTPS traffic in a device he controls or have induced the user to install custom certificates, but this can be prevented with the use of certificate pinning.
You can learn more about how a MitM attack is carried out in my article Steal that Api Key with a Man in the Middle Attack:
Securing HTTPS with Certificate Pinning
To prevent MitM attacks to occur you can deploy certificate pinning on your mobile app, and you can learn more about in my article Securing HTTPS with Certificate Pinning:
This article will show you how to use the Mobile Certificate Pinning Generator, an online free tool that will give you ready to use configuration files for Android and iOS with pinning configured.
Simply add the API domain to pin against:
And then copy and paste the configuration into your Android app:
Please be aware of the trade-offs and pitfalls of using static certificate pinning by reading the tool faq tab:
Do You Want To Go The Extra Mile?
In any response to a security question I always like to reference the excellent work from the OWASP foundation.
For APIS
OWASP API Security Top 10
For Mobile Apps
OWASP Mobile Security Project - Top 10 risks
OWASP - Mobile Security Testing Guide:
应确保在互联网上暴露的任何事物。您知道只有您的应用程序会拨打您的API,但是如果不固定API,那么任何人都可以开始调用您的API并假装它们是您的Android应用程序。恶意演员将能够使用该应用程序可以做的所有事情 - 读取用户的数据,修改它们等。HTTPS
也是如此。使用HTTP旨在保护服务器和应用程序之间的流量。不管您只有一个消耗API的应用程序都没关系。如果您不使用HTTP,那么任何人都可以窃听您的流量。
Anything which is exposed on the Internet should be secured. You know that only your app will call your API, but if the API is not secured then anyone can start calling your API and pretend they are your Android app. The malicious actor will be able to do with your API everything that the app could do - read users' data, modify them, etc.
The same goes for HTTPS. Using HTTPS is meant to protect the traffic between your server and your app. It doesn't matter whether you will have only one app consuming the API. If you don't use HTTPS, then anyone can eavesdrop your traffic.