.net - AWS 开发工具包 CryptProtectData 失败

标签 .net amazon-web-services aws-sdk

我正在使用适用于.net的aws sdk,在emr集群中创建pig事件并在管道中调用,

try
{
    var profileName = ConfigurationManager.AppSettings["AWS_PROFILE_NAME"];
    var accessKey = ConfigurationManager.AppSettings["AWS_ACCESS_KEY"];
    var secretKey = ConfigurationManager.AppSettings["AWS_SECRET_KEY"];

    Amazon.Util.ProfileManager.RegisterProfile(profileName, accessKey, secretKey);

    using (_dataPipelineClient = new AmazonDataPipelineClient(accessKey, secretKey, Amazon.RegionEndpoint.USEast1))
    {
        //proccesing code ...
    }    
}
catch (Exception e)
{
    Logger.Error("ReportScheduler -> Error ocurred.", e);
    throw new Exception("ReportScheduler -> Error ocurred.", e);
}

在我的本地服务器中,一切都运行完美,没有任何问题。但在托管中它抛出此异常:

AmazonClient异常

CryptProtectData 失败。

Amazon.Runtime.Internal.Settings.UserCrypto in Encrypt at line 94:0
    System.String Encrypt(System.String)

Amazon.Runtime.Internal.Settings.SettingsCollection+ObjectSettings in WriteToJson at line 94:0
    Void WriteToJson(ThirdParty.Json.LitJson.JsonWriter)

Amazon.Runtime.Internal.Settings.SettingsCollection in Persist at line 62:0
    Void Persist(System.IO.StreamWriter)

Amazon.Runtime.Internal.Settings.PersistenceManager in saveSettingsType at line 93:0
    Void saveSettingsType(System.String, Amazon.Runtime.Internal.Settings.SettingsCollection)

Amazon.Util.ProfileManager in RegisterProfile at line 115:0
    Void RegisterProfile(System.String, System.String, System.String)

有人可以告诉我问题出在哪里吗?

谢谢。

最佳答案

我遇到了同样的问题,对我有用的是使用基本的 AWS 凭证,而不是使用商店凭证。

    public static AmazonS3Client GetAwsS3Client(string accessKey, string secretKey)
    {
        var credentials = new BasicAWSCredentials(accessKey, secretKey);

        return new AmazonS3Client(credentials, Amazon.RegionEndpoint.USEast1);
    }

关于.net - AWS 开发工具包 CryptProtectData 失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32461275/

相关文章:

c# - 我如何在 NANT 或 csc.exe 中包含对 Web 服务的引用?

.net - .NET 中 TreeView 的延迟加载

aws-sdk - AWS Pinpoint 中设备的终端节点是唯一的吗?

c# - 如何将进程输出重定向到 System.String

.net - 性能计数器在 ReadOnly=false 时显示不同的值

amazon-web-services - 无效资源和格式错误的策略错误 - aws cloudformation YAML

r - AWS EC2 上使用 h2o 进行多节点集群安装

amazon-web-services - 如何在CDK中获取AWS IoT自定义终端节点?

node.js - 无法使用 AWS SES : didn't I configure it properly? 发送电子邮件

javascript - AWS SDK 等待异步调用完成?