Amazon EC2 - HTTPS - 证书正文无效。正文不得包含私钥

Amazon EC2 - HTTPS - 证书正文无效。正文不得包含私钥

我对 Amazon EC2 还很陌生。我正在尝试为我的网站设置 https,我遵循 amazon doc 的官方说明:http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/configuring-https.html

当我使用 AWS 命令​​上传签名证书时

aws iam upload-server-certificate --server-certificate-name dichcumga --certificate-body file://mycert.pem --private-key file://signedkey.pem --certificate-chain file://mychain.pem

我得到了错误

调用 UploadServerCertificate 操作时发生客户端错误 (MalformedCertificate):证书正文无效。正文中不得包含私钥。

mycert.pem 是 private.pem 和signedkey.pem(由VeriSign返回)的组合

copy private.pem+signedkey.pem mycert.pem

请帮忙解释一下。先谢谢了。

[更新 1 - 2014 年 8 月 21 日]:CA 返回的公共证书问题

根据@mezi的建议,我按照以下说明进行操作:http://docs.aws.amazon.com/ElasticLoadBalancing/latest/DeveloperGuide/ssl-server-cert.html

但是我遇到了 CA 返回的公共证书问题。

  • 我提交 CSR 请求
  • CA 向我返回一封电子邮件,其中包含纯文本形式的公共证书

-----开始证书----- MIAGCSqGSIb3DQEHAqCAMIACAQExADALBgkqhkiG9w0BBwGggDCCBPYwggPeoAMC AQICED0qLOh43VCbqW0sDf5mb+swDQYJKoZIhvcNAQEFBQAwgcsxCzAJBgNVBAYT AlVTMRcwFQYDVQQKEw5WZXJpU2lnbiwgSW5jLjEwMC4​​GA1UECxMnRm9yIFRlc3Qg UHVycG9zZXMgT25seS4gIE5vIGFzc3VyYW5jZXMuMUIwQAYDVQQLEzlUZXJtcyBv ZiB1c2UgYXQgaHR0cHM6Ly93d3cudmVyaXNpZ24uY29tL2Nwcy90ZXN0Y2EgKGMp MDkxLTArBgNVBAMTJFZlcmlTaWduIFRyaWFsIFNlY3VyZSBTZXJ2ZXIgQ0EgLSBH MjAeFw0xNDA4MjEwMDAwMDBaFw0xNDA5MjAyMzU5NTlaMFwxCzAJBgNVBAYTAlZO MRIwEAYDVQQIEwlIb0NoaU1p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-----结束证书-----

  • 接下来,我将代码复制到记事本并另存为公共.pem文件
  • 然后我使用 openssl 命令来检查它是否是 PEM 格式

openssl x509-通知 PEM-in公共.pem

我得到了错误

无法加载证书 1952:错误:0D0680A8:asn1 编码例程:ASN1_CHECK_TLEN:错误标签:.\crypto\as n1\tasn_dec.c:1319: 1952:错误:0D07803A:asn1 编码例程:ASN1_ITEM_EX_D2I:嵌套的 asn1 错误:.\ crypto\asn1\tasn_dec.c:381:Type=X509_CINF 1952:错误:0D08303A:asn1 编码例程:ASN1_TEMPLATE_NOEXP_D2I:嵌套的 asn1 e 错误:.\crypto\asn1\tasn_dec.c:751:Field=cert_info,Type=X509 1952:错误:0906700D:PEM例程:PEM_ASN1_read_bio:ASN1 lib:\crypto\pem\pem_oth.c:83:

--> 这不是 PEM 格式,我这里犯了一个错误,请帮忙吗?

答案1

该文件(更新 1)是 PEM 格式的 - 假设破折号-BEGIN-CERTIFICATE-dashes 和破折号-END-CERTIFICATE-dashes 实际上是在不同的行上,从粘贴格式中看不清楚 - 但事实并非如此证书采用 PEM 格式。PEM 格式用于多种不同类型的对象。这是一个带有空数据和两个证书的 PKCS7/CMS 签名数据:一个用于 Epinion dichcum.ga 的 EE 证书和一个用于 Verisign Trial Secure Server CA G2 的 CA(链)证书。这种格式(带有空数据和证书的 PKCS7 签名数据)是分发相关证书的常用方法,通常称为“p7b”或“p7c”。

CERTIFICATE将BEGIN 和 END 行中的单词更改为PKCS7.Run openssl pkcs7 -print_certs <public.pem >tempfile。输出文件tempfile将包含每个文本块由一个 BEGIN 行、几行数据和一个 END 行组成。使用任何文本编辑器或 sed 等实用程序将这些块放在单独的文件中,比如说mycert.pemchaincert.pem。将第一个文件作为您的证书上传,将第二个文件作为链证书上传,以及您的私钥文件(显然是private.pem)。

相关内容