Anyone can decompile the APK and get my secret and access keys,
What is the right way to initialize the s3 client and use the s3 bucket storage?
Even in AWS documentation, the deprecated method is mentioned. Please guide.
AWSConfiguration config = new AWSConfiguration(context);
transferUtility = TransferUtility.builder()
.context(context)
.awsConfiguration(config)
.s3Client(new AmazonS3Client(new CognitoCachingCredentialsProvider(context, config)))
.build();
Caused by java.lang.IllegalArgumentException
TransferUtility has not been configured with a default bucket. Please use the corresponding method that specifies the bucket name or configure the default bucket name in construction of the object. See TransferUtility.builder().defaultBucket() or TransferUtility.builder().awsConfiguration()
BasicAWSCredentials awsCreds = new BasicAWSCredentials("access_key_id", "secret_key_id");
AmazonS3Client s3Client = new AmazonS3Client(awsCreds, Region.getRegion(Regions.US_EAST_2));
Anyone can decompile the APK and get my secret and access keys.
@kvasukib sir please see this.
@mbk820 Your concern is valid. I would recommend you to use Amazon Cognito Identity Pools which retrieves a set of temporary credentials (AWS Access and Secret Access Keys) that are valid for an hour and the SDK retrieves new credentials after the expiration.
AWSConfiguration awsConfiguration = new AWSConfiguration(getApplicationContext());
CognitoCachingCredentialsProvider awsCreds = new CognitoCachingCredentialsProvider(getApplicationContext(), awsConfiguration);
AmazonS3Client s3Client = new AmazonS3Client(awsCreds, Region.getRegion(Regions.US_EAST_2));
TransferUtility transferUtility = TransferUtility.builder()
.context(getApplicationContext())
.awsConfiguration(awsConfiguration)
.s3Client(s3Client)
.build();
Take a look at our documentation for more details: https://aws-amplify.github.io/docs/android/storage
@kvasukib Hi dear, Hope you are fine, We are using s3 paid services, Our app is live with a lot of users, our users are facing ANRs while initializing 'CognitoCachingCredentialsProvider' and creating 'TransferUtility' object, and some other ANRs, all are related AWS. We have to load a lot of images from s3 storage at runtime while the user scrolling the recycle view.
This is ANR stats, Please give some time, and provide a solution.
`
"main" prio=5 tid=1 Native
| group="main" sCount=1 dsCount=0 flags=1 obj=0x74b64f70 self=0xadabb000
| sysTid=1445 nice=-10 cgrp=default sched=0/0 handle=0xb2136494
| state=S schedstat=( 5851335831 555704094 4259 ) utm=467 stm=116 core=5 HZ=100
| stack=0xbe09b000-0xbe09d000 stackSize=8MB
| held mutexes=
#00 pc 000000000005377c /system/lib/libc.so (__ioctl+8)
#01 pc 00000000000219f3 /system/lib/libc.so (ioctl+30)
#02 pc 000000000003d451 /system/lib/libbinder.so (android::IPCThreadState::talkWithDriver(bool)+168)
#03 pc 000000000003ddff /system/lib/libbinder.so (android::IPCThreadState::waitForResponse(android::Parcel, int)+26)
#04 pc 00000000000371bd /system/lib/libbinder.so (android::BpBinder::transact(unsigned int, android::Parcel const&, android::Parcel, unsigned int)+36)
#05 pc 00000000000c3fe7 /system/lib/libandroid_runtime.so (android_os_BinderProxy_transact(_JNIEnv, _jobject, int, _jobject, _jobject*, int)+82)
at android.os.BinderProxy.transactNative (Native method)
at android.os.BinderProxy.transact (Binder.java:1136)
at android.security.IKeystoreService$Stub$Proxy.finish (IKeystoreService.java:1404)
at android.security.KeyStore.finish (KeyStore.java:581)
at android.security.keystore.KeyStoreCryptoOperationChunkedStreamer$MainDataStream.finish (KeyStoreCryptoOperationChunkedStreamer.java:338)
at android.security.keystore.KeyStoreCryptoOperationChunkedStreamer.doFinal (KeyStoreCryptoOperationChunkedStreamer.java:220)
at android.security.keystore.AndroidKeyStoreAuthenticatedAESCipherSpi$BufferAllOutputUntilDoFinalStreamer.doFinal (AndroidKeyStoreAuthenticatedAESCipherSpi.java:373)
at android.security.keystore.AndroidKeyStoreCipherSpiBase.engineDoFinal (AndroidKeyStoreCipherSpiBase.java:506)
at javax.crypto.Cipher.doFinal (Cipher.java:2055)
at com.amazonaws.internal.keyvaluestore.AWSKeyValueStore.decrypt (AWSKeyValueStore.java:360)
at com.amazonaws.internal.keyvaluestore.AWSKeyValueStore.get (AWSKeyValueStore.java:207)
Thanks for the update. @kvasukib Can you make a note of this crash?
@mbk820 Thank you for the bug report. I will track this crash as part of #937 issue. Closing this issue.
Most helpful comment
@mbk820 Your concern is valid. I would recommend you to use Amazon Cognito Identity Pools which retrieves a set of temporary credentials (AWS Access and Secret Access Keys) that are valid for an hour and the SDK retrieves new credentials after the expiration.
Take a look at our documentation for more details: https://aws-amplify.github.io/docs/android/storage