简体   繁体   English

.NET Core 2.1 上 AWS Secrets Manager GetSecretValueAsync 上的套接字异常

[英]Socket exception on AWS Secrets Manager GetSecretValueAsync on .NET Core 2.1

I have been struggling to implement secrets manager on .NET Core.我一直在努力在 .NET Core 上实现机密管理器。 It always returning me with Socket Exception and HTTPRequestException on GetSecretValueAsync method call, while it is working on my colleagues PC.当它在我同事的 PC 上工作时,它总是在 GetSecretValueAsync 方法调用上返回 Socket Exception 和 HTTPRequestException。

SocketException: A socket operation was attempted to an unreachable network HttpRequestException: A socket operation was attempted to an unreachable network SocketException:尝试对无法访问的网络进行套接字操作 HttpRequestException:尝试对无法访问的网络进行套接字操作HttpRequestExceptionSocketException

I have already setup the credentials file needed in AWS default profile located at C:\\Users\\USERNAME.aws\\credentials on Windows and also on each IIS App Pool .aws folder.我已经在位于 Windows 上的 C:\\Users\\USERNAME.aws\\credentials 以及每个 IIS App Pool .aws 文件夹中的 AWS 默认配置文件中设置了所需的凭证文件。 All credentials stored in UTF-8 format previously ANSI.以前 ANSI 以 UTF-8 格式存储的所有凭据。

Here is sample of the credentials that i got with MFA authentication:这是我通过 MFA 身份验证获得的凭据示例:AWS credentials file Here is my aws credentials configuration and folder location:这是我的 aws 凭据配置和文件夹位置:Credentials location Mostly my setting with my colleague are the same.大多数情况下,我和同事的设置是一样的。 Now I'm almost at a dead end.现在我几乎走到了死胡同。 If anybody have experience or AWS Web Services Team willing to help me with the solution for this, please let me know.如果有人有经验或 AWS Web 服务团队愿意帮助我解决此问题,请告诉我。 Thank you.谢谢你。 Cheers.干杯。

var data = secretManager.GetSecretValueAsync(
    new GetSecretValueRequest
    {
        SecretId = configName
    }
).Result;

UPDATE: I found out the real issue here but still got no solution yet.更新:我在这里发现了真正的问题,但仍然没有解决方案。 Because I can't really see where does the secrets manager get the credentials from.因为我真的看不到机密管理器从哪里获得凭据。 And for your information, this method works on .NET Framework in my PC.供您参考,此方法适用于我 PC 中的 .NET Framework。Issue found

Need more info to help .需要更多信息来帮助。 1. the path for aws credentials is usually C:\\Users\\USERNAME.aws\\ not C:\\Users\\USERNAME.aws\\ 1. aws 凭证的路径通常是 C:\\Users\\USERNAME.aws\\ 而不是 C:\\Users\\USERNAME.aws\\
2. in this folder should be a file named config where the region is defined. 2.在这个文件夹中应该有一个名为config的文件,其中定义了区域。 Put the region where the AWS Secrets Manager is configured.放置配置 AWS Secrets Manager 的区域。 Here an example这里有一个例子

[default]
region = us-east-1

If this is not helping describe the configuration please如果这对描述配置没有帮助,请

I have finally found out the real issue here.我终于在这里找到了真正的问题。 It is actually because I need to allow IIS_IUSRS group user to access IIS system profile folder.这实际上是因为我需要允许 IIS_IUSRS 组用户访问 IIS 系统配置文件文件夹。 Thank you everyone!谢谢大家!

IIS system profile folder

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM