亚马逊AWS无法验证解密证书链

时间:2015-02-02 10:15:26

标签: ssl amazon-web-services https amazon-cloudfront thawte

我刚获得了Thawte 123 SSL证书,并且在将其上传到AWS以将其与CloudFront一起用作自定义SNI SSL证书时出现问题。 AWS拒绝CA Chain。我正在使用Thawte Intermediate CA bundle SSL Web Server and Thawte Wildcard certificates

为了能够使用我的私钥,我将其转换为RSA密钥:

openssl rsa -in private.key -out private-rsa-key.pem`

并尝试上传:

aws iam upload-server-certificate --server-certificate-name example.com-certificate --certificate-body file://certificate.pem --private-key file://private.pem --certificate-chain https://search.thawte.com/library/VERISIGN/ALL_OTHER/thawte%20ca/SSL_CA_Bundle.pem --path /cloudfront/example.com/

导致以下错误:

A client error (MalformedCertificate) occurred when calling the UploadServerCertificate operation: Unable to validate certificate chain. The certificate chain must start with the immediate signing certificate, followed by any intermediaries in order. The index within the chain of the invalid certificate is: 0

即使将thawte_Primary_Root_CA.pem作为第一个即时签名证书插入证书链,也无法解决问题。

A client error (MalformedCertificate) occurred when calling the UploadServerCertificate operation: Unable to validate certificate chain. The certificate chain must start with the immediate signing certificate, followed by any intermediaries in order. The index within the chain of the invalid certificate is: 1

Thawte CA Chain是否与AWS不兼容?

4 个答案:

答案 0 :(得分:1)

我现在遇到同样的问题,并尝试了一切。 使用SSL123证书(我的rsa密钥和pem都可以)

我无法以任何顺序开始工作Thawte提供的主要和次要证书。 我尝试过单独使用primary,仅使用secondary,primary + secondary,secondary + primary,也尝试使用root cert,并尝试使用primary& secondary from:

https://search.thawte.com/library/VERISIGN/ALL_OTHER/thawte%20ca/SSL123_SecondaryCA.pem

https://search.thawte.com/library/VERISIGN/ALL_OTHER/thawte%20ca/SSL123_PrimaryCA.pem

我唯一可以从ELB获得的是:

无法验证证书链。证书链必须以即时签名证书开头,然后依次是任何中间人。无效证书链中的索引是:0

索引不总是-1,但也是0,1和2,具体取决于所包含的顺序和证书数量。

[为我解决]

显然,您创建证书的EC2实例会影响。我使用了默认AMI的标准EBS实例,并再次转换了Thwate提供的证书,并且确实有效。

这里的步骤:

CSR:

keytool -genkey -keysize 2048 -keyalg RSA -alias mycertificate -keystore keystore.jks

一旦Thatwe响应:(主要是电子邮件链中的第二个证书)。

在keystore.jks中导入三个证书

keytool -import -alias Primary -trustcacerts -file Primary.crt -keystore keystore.jks
keytool -import -alias Secondary -trustcacerts -file Secondary.crt -keystore keystore.jks
keytool -import -alias mycertificate -trustcacerts -file mycertificate.cer -keystore keystore.jks

JSK> P12 - 将keystore.jks转换为p12格式

keytool -importkeystore -srckeystore keystore.jsk -destkeystore keystore.p12 -srcstoretype jks -deststoretype pkcs12

P12> PEM - 将p12格式转换为pem格式

openssl pkcs12 -in keystore.p12 -out keystore.pem -nodes

PEM> RSA私钥 - 以RSA格式导出私钥

openssl rsa -in keystore.pem -text> keystore_rsa.pem

这次确实有效。

答案 1 :(得分:0)

答案 2 :(得分:0)

请务必注意,中间证书并非特定于您的域或证书。因此,每张与您相同的证书都具有完全相同的中间证书。

您可以将它们视为支票上的路由号码。需要路由号码,但真正说明您的银行比关于您的更多。在这种情况下,您的帐号或您的证书是您的独特之处。

由于中间证书的通用性,有类似这样的网站:

https://docs.djangoproject.com/en/1.11/ref/contrib/postgres/fields/#jsonfield

对于不同的证书颁发者,所有中间证书都预先捆绑(并且顺序正确)。

答案 3 :(得分:0)

  1. 您必须确保证书,私钥和证书链都经过PEM编码,如下所示:
-----BEGIN CERTIFICATE----- << -This is my Intermediate CA which signed my CSR 
Base64-encoded certificate
-----END CERTIFICATE-----
-----BEGIN CERTIFICATE----- << -This is my Root CA which signed my Intermediate CA
Base64-encoded certificate
-----END CERTIFICATE-----
  1. 您不需要将签名证书放在链中。
    只需在Chain文件中添加中间和根ca即可。