大网数据广告活动
服务器运维问答

Add existing wildcard SSL certificate to Amazon EC2 Nginx

· 52CE 我爱测

I'm trying to add a pre-existing wildcard SSL certificate to a single Ubuntu instance on Amazon EC2, where the webserver is Nginx, and I run a single subdomain. I have - from the original vendor who provides the certificate - fil…

问题原文

原帖链接 · Jonathan Stegall · CC BY-SA 3.0

I'm trying to add a pre-existing wildcard SSL certificate to a single Ubuntu instance on Amazon EC2, where the webserver is Nginx, and I run a single subdomain.

I have - from the original vendor who provides the certificate - files named private.key, selfsigned.crt, and ssl-shared-cert.inc. I've uploaded these files to EC2, at /etc/nginx/ssl (which is a new folder I've created). I've previously used the same files on Heroku, though the process seems to be quite specific there. They're also used on our main domain (https://wwww.minnpost.com), but I was not involved in setting them up there, as I believe our hosting vendor did it for us.

ssl-shared-cert looks like this:

SSLEngine On
SSLProtocol all -SSLv2 -SSLv3
SSLCipherSuite ALL:!ADH:!EXPORT:!SSLv2:RC4+RSA:+HIGH:+MEDIUM:+LOW
SSLCertificateFile "/path/to/selfsigned.crt"
SSLCertificateKeyFile "/path/to/private.key"

On my EC2 instance, I've changed my site's configuration to:

server {
    listen 8080;
    listen 443 ssl;
    server_name subdomainurl;
    ssl_certificate /etc/nginx/ssl/selfsigned.crt;
    ssl_certificate_key /etc/nginx/ssl/private.key;
    root path;
    ...
}

When I run sudo nginx -t I get the following:

nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful

So I ran sudo service nginx restart, and this returned OK. First I checked to make sure the HTTP version still worked, and it does, but the HTTPS still does not. When I run curl, it returns:

* SSL certificate problem: Invalid certificate chain
* Closing connection 0
curl: (60) SSL certificate problem: Invalid certificate chain
More details here: http://curl.haxx.se/docs/sslcerts.html

Where can I go from here?

已采纳解答

原帖链接 · DerfK · CC BY-SA 3.0

If the certificate is not actually self-signed then there's two possibilities that I can think of. The first is that curl is missing the bundle of trusted authorities (Debian keeps a set of trusted certs in a package named ca-certificates). If this is the case then no https site would work with it. Can you check that your curl is working with other sites?

If curl is working then what you are missing is likely the chain of certificates that the signer should have provided that links the signature on your certificate with one of the primary trusted certificates. From the instructions here you should add the certificate chain (with each certificate in PEM format) to the end of selfsigned.crt (the server's own certificate must be first).

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2016-02-24)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。