我通过运行好的 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.
我尝试过的修改。
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/