openssl - 无法为 Cloudfront 制作有效的 IAM SSL 证书

标签 openssl ssl-certificate amazon-cloudfront pem amazon-iam

我通过运行好的 ole 创建了一个 CSR

$ openssl req -nodes -newkey rsa:4096 -keyout example.key -out example.csr

这产生了一个 example.csr 和 example.key

然后,我对其进行了签名并收到了 4 个 .crt 文件。我的域 .crt、2 个中间体和根。

从这里:http://docs.aws.amazon.com/IAM/latest/APIReference/API_UploadServerCertificate.html ,我认为亚马逊希望我的私钥是 PEM 编码的,所以我跑了
$ openssl rsa -in example.key -text > example.pem

Cloudfront 还想要他们所谓的 CertificateChain,来自 https://bryce.fisher-fleig.org/blog/setting-up-ssl-on-aws-cloudfront-and-s3/http://docs.aws.amazon.com/IAM/latest/UserGuide/InstallCert.html#SampleCert ,似乎该文件应该是连接在一起的 2 个中间证书。所以我使用文本编辑器制作了该文件并将其命名为 example.crt.chain

最后,拿着这一切,我跑了
$ aws iam upload-server-certificate --server-certificate-name star-assets-example-com --certificate-body file://STAR_assets_example_com.crt --private-key file://example.pem --certificate-chain file://example.crt.chain --path /cloudfront/assets/

那返回给我“ServerCertificateMetadata”。最后,我转到 Cloudfront 控制台并尝试将该证书设置为 cloudfront 的“自定义 SSL 证书”。但是,它告诉我
AWS Error Code: InvalidViewerCertificate, AWS Error Message: The specified SSL certificate doesn't exist in the IAM certificate store, isn't valid, or doesn't include a valid certificate chain.

我尝试过的修改。
  • 在链中包括和不包括根证书。两者都上传但都不起作用。
  • 我尝试从 PEM 文件的头部删除“模数”、“privateExponent”、“prime1”等,以便它只包含“-----BEGIN RSA PRIVATE KEY-----...- ----END RSA PRIVATE KEY-----”的东西,就像 AWS 文章所建议的那样。两者都上传但都不起作用。
  • 更改我的链文件中证书的顺序会导致上传工具出现无效错误。
  • 不包括证书链,但这显然与 cloudfront 所说的我需要的背道而驰。
  • 使用我原来的 example.key 文件而不是 openssl rsa编码的 PEM 文件。这会从上传工具中产生错误。该文件的格式为“-----BEGIN PRIVATE KEY-----...-----END PRIVATE KEY-----”
  • 最佳答案

    所以事实证明我的错误只是我的证书大小太长。最大长度是 2048,而我的是 4096!我通过在此处阅读类似问题找到了我的问题 Having trouble associated SSL cert with Amazon Cloudfront

    我想这就是晦涩难懂的“无效”的意思。我真的希望有更多的验证和更好的错误消息!!!!

    关于openssl - 无法为 Cloudfront 制作有效的 IAM SSL 证书,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25415791/

    相关文章:

    php - 如何使用密码正确加密 JS 生成的 RSA 私钥?

    ios - 在 Windows for iPhone 应用程序上将推送证书转换为 P12 格式

    java - 忽略证书时出现 CertificateException

    openssl - 客户端向您提供其公共(public)证书时的相互认证

    amazon-web-services - Amazon CloudFront key 对创建

    rsa - 如何从 RSA 私钥中提取私钥组件 $N$ 和 $D$?

    apache - OpenSSL 在 csr 文件中生成未知的电子邮件地址?

    java - SSL:客户端身份验证,同一商店中的多个证书版本

    php - 使用 openssl sha1 -sign 和 PHP 的 openssl_sign 时,CloudFront 签名 URL 的签名不同

    amazon-web-services - AWS CloudFront 签名的 cookies + S3 适用于 REST 客户端应用程序,但不适用于浏览器