在 Android 项目中处理 AWS 凭证的正确方法是什么?

kib*_*yte 5 java security android amazon-web-services

我需要在我的 Android 应用程序中连接到 Amazon 的 SimpleDB。Amazon Android SDK提供的示例项目将凭证放置在名为 AwsCredentials.properties 的文件中,该文件位于项目源代码中。然后源代码进行这些调用来访问和使用它们:

Properties properties = new Properties();
properties.load( getClass().getResourceAsStream( "AwsCredentials.properties" ) );

String accessKeyId = properties.getProperty( "accessKey" );
String secretKey = properties.getProperty( "secretKey" );
...
credentials = new BasicAWSCredentials( properties.getProperty( "accessKey" ), properties.getProperty( "secretKey" ) );
Run Code Online (Sandbox Code Playgroud)

这是正确且安全的方法吗?

Ben*_*enM 4

我不会那样做。它适合快速组合某些内容,但将 AWS 凭证存储在属性文件中并不是安全的方法。Amazon 实际上提供了一篇关于如何从移动设备安全访问 AWS 的有用文章。我还建议查看Android 提供的 KeyStore

我在对您的其他问题的回复中写了有关使用 IAM 用户获取移动 AWS 凭证的更多详细信息。