【问题标题】:x509: certificate is valid for *<rest-of-hostname>, not <bucket/hostname>x509:证书对 *<rest-of-hostname> 有效,而不是 <bucket/hostname>
【发布时间】:2021-06-21 12:16:06
【问题描述】:

我正在尝试使用 Go SDK 将文件上传到 Amazon S3 存储桶到自定义端点,但我收到了该错误:

RequestError: send request failed caused by: Put https://<bucket>.<custom-endpoint>/sample.tar.gz: x509: certificate is valid  for *<hostname>, not <bucket/hostname>

自定义端点的证书在通用名称 (*.) 的开头包含一个通配符,我应该在此推断通配符将涵盖它尝试执行的请求。

我尝试用Python3和boto3包上传文件,结果成功。

您能就此提出建议吗?

【问题讨论】:

  • 不可能确定您的编辑,但例如,如果您有通配符*.example.com 的证书,则它对a.example.comb.example.com 有效,但不适用于example.com。另请注意,至少十年内的大多数证书都具有 SubjectAlternativeName (SAN) 扩展名,如果是这样,CommonName 将被忽略且不使用。每个都有几十个现有的 Q。

标签: amazon-web-services go ssl amazon-s3 x509


【解决方案1】:

您可以简单地将“bucket”一词放在 vpc 端点的前面。因此,如果您的端点是:

*.vpce-09f99bc99983c51-188851c5.s3.us-east-1.vpce.amazonaws.com

在您的配置(用于 EndpointResolver)中,您应该使用:

https://bucket.vpce-09f99bc99983c51-188851c5.s3.us-east-1.vpce.amazonaws.com

返回 EndpointResolverFunc 时不要忘记设置 URL、SigningRegion 和 Source

【讨论】: