【问题标题】:TrustFailure Error Thrown When Using AWS Powershell使用 AWS Powershell 时引发 TrustFailure 错误
【发布时间】:2017-10-13 19:08:57
【问题描述】:

我正在尝试使用 AWS powershell 来更新我的 S3 存储桶中项目的元数据。我正在使用脚本:

Set-AWSCredentials -ProfileName S3Test ;
write-S3Object -BucketName myS3bucket `
               -Key Folder/Subfolder/Myfile.txt `
               -Content "Myfile.txt `
               -Metadata @{"x-amz-meta-custommetadata" = "TESTMEtadata"} `
               -Headers @{"Content-Type" = "binary/octet-stream"} ;

我能够从我自己的计算机上的帐户成功运行此脚本,但是当我尝试使用服务帐户自动执行此脚本时,我收到了错误消息:

write-S3Object : A WebException with status TrustFailure was thrown.
At line:1 char:1
+ write-S3Object -BucketName myS3Bucket `
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: 
(Amazon.PowerShe...eS3ObjectCmdlet:WriteS3ObjectCmdlet) [Write-S3Obje
   t], InvalidOperationException
    + FullyQualifiedErrorId : 

Amazon.Runtime.AmazonServiceException,Amazon.PowerShell.Cmdlets.S3.WriteS3ObjectCmdlet

根据我在类似问题上的发现,我尝试将此行添加到我的脚本中:

[System.Net.ServicePointManager]::ServerCertificateValidationCallback = {$true} ;

但是这会导致不同的错误消息:

write-S3Object : A WebException with status RecieveFailure was thrown.
At line:1 char:1
+ write-S3Object -BucketName myS3Bucket `
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: 
(Amazon.PowerShe...eS3ObjectCmdlet:WriteS3ObjectCmdlet) [Write-S3Obje
   t], InvalidOperationException
    + FullyQualifiedErrorId : 

Amazon.Runtime.AmazonServiceException,Amazon.PowerShell.Cmdlets.S3.WriteS3ObjectCmdlet

有谁知道可能导致这些问题的原因以及我将如何解决这些问题?

【问题讨论】:

    标签: powershell amazon-web-services amazon-s3


    【解决方案1】:

    似乎使用以下定义的内容运行回调:

    [System.Net.ServicePointManager]::ServerCertificateValidationCallback = {$true}

    根据我阅读的内容,我不确定是什么触发了它,但回调似乎是在服务帐户上设置的。

    尝试将其设置为:

    [System.Net.ServicePointManager]::ServerCertificateValidationCallback = $null
    

    参考:

    https://forrestbrazeal.com/2015/06/15/adventures-in-aws-the-worlds-scariest-stack-trace/

    【讨论】:

    • 不幸的是,当我将此行添加到我的脚本时,生成的第一个错误再次开始: write-S3Object : A WebException with status TrustFailure was throwed。在 line:1 char:1 + write-S3Object -BucketName myS3Bucket ` + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidOperation: (Amazon.PowerShe...eS3ObjectCmdlet:WriteS3ObjectCmdlet) [Write-S3Obje t] , InvalidOperationException + FullyQualifiedErrorId : Amazon.Runtime.AmazonServiceException,Amazon.PowerShell.Cmdlets.S3.WriteS3ObjectCmdlet
    • 您是否使用服务帐户在您自己以外的另一台机器上运行此程序?
    • 我的想法是(从我看来,这似乎是正确的)“信任失败”表明 AWS SSL/TLS 证书颁发者根证书不在您机器的根证书存储中正在使用服务帐户运行脚本。检查故障机器上的受信任根存储中是否有“Starfield Class 2 证书颁发机构”。
    【解决方案2】:

    在服务器上检查您的日期。

    我在访问 AWS 端点时遇到了同样的错误,但解决方案稍微简单了一点……我正在测试一个过程,我将服务器上的日期设置回了几个月,这导致 AWS 连接过程抛出请求出去。

    【讨论】:

      猜你喜欢
      • 2021-02-12
      • 1970-01-01
      • 1970-01-01
      • 2022-07-24
      • 2021-08-14
      • 2020-05-04
      • 2017-02-07
      • 1970-01-01
      • 2020-07-31
      相关资源
      最近更新 更多