【问题标题】:Reading Encrypted Data from S3从 S3 读取加密数据
【发布时间】:2017-11-10 13:51:02
【问题描述】:

我必须从 S3 存储桶下载数据,数据已加密,并且我拥有用于​​解密数据的 kms 密钥。代码在 EC2 实例中运行,并且 EC2 实例具有从 S3 读取的 IAM 角色。 我在this 链接中看到了示例代码,但我无法阅读内容。我收到以下异常

Exception in thread "main" com.amazonaws.SdkClientException: Unable to load credentials into profile [default]: AWS Access Key ID is not specified.
        at com.amazonaws.auth.profile.internal.ProfileStaticCredentialsProvider.fromStaticCredentials(ProfileStaticCredentialsProvider.java:55)
        at com.amazonaws.auth.profile.internal.ProfileStaticCredentialsProvider.<init>(ProfileStaticCredentialsProvider.java:40)
        at com.amazonaws.auth.profile.ProfilesConfigFile.fromProfile(ProfilesConfigFile.java:207)
        at com.amazonaws.auth.profile.ProfilesConfigFile.getCredentials(ProfilesConfigFile.java:160)

有人可以建议我哪里出错了,或者就如何在没有凭据的情况下从 S3 存储桶读取加密数据提供一些指导

【问题讨论】:

    标签: java amazon-s3 amazon-ec2


    【解决方案1】:

    我能够通过提供 InstanceProfileCredentialsProvider 找到解决方案。下面是代码。

     String kms_key = Constants.KMS_key;
            String inputString = null;
            KMSEncryptionMaterialsProvider materialProvider = new KMSEncryptionMaterialsProvider(kms_key);
            AmazonS3EncryptionClient client = new AmazonS3EncryptionClient(InstanceProfileCredentialsProvider.getInstance(),
                    materialProvider);
            S3Object downloadedObject = client.getObject(bucketName, filePath);
            if (null != downloadedObject) {
                inputString = convertToString(downloadedObject.getObjectContent());
            }
    

    【讨论】:

      猜你喜欢
      • 2019-09-21
      • 2020-04-13
      • 2016-02-09
      • 1970-01-01
      • 2019-06-16
      • 2016-02-20
      • 2015-08-04
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多