A
A
Alexey Kuzmin2015-11-25 09:24:56
Nginx
Alexey Kuzmin, 2015-11-25 09:24:56

How to add an SSL certificate to Nginx?

Hello everyone
How to add an ssl certificate to Nginx? It seems that everything was done as it should (and the certificate was purchased):

server {
    listen      443 ssl;
    server_name hostname;

    ssl_certificate      /etc/ssl/private/project.pem;
    ssl_certificate_key  /etc/ssl/private/project.key;

    ssl_session_cache   shared:SSL:10m;
    ssl_session_timeout  5m;
    ssl_prefer_server_ciphers   on;

    location /  {
        # ....
    }
}

When I log in via chrome it says:
Ваше подключение не защищено
Злоумышленники могут пытаться похитить ваши данные
с сайта hostname.ru (например, пароли, сообщения или номера банковских карт). 
NET::ERR_CERT_AUTHORITY_INVALID

Answer the question

In order to leave comments, you need to log in

4 answer(s)
A
Alexey Romanenko, 2015-11-25
@slimus

What's in the logs?

N
nonname, 2015-11-25
@nonname

Does the public key only contain the certificate itself or the chain? Most likely there is such a chain as ROOT CA - Intermediate - your certificate, it would be nice to download more Intermediate and blind them together with yours. nginx.org/ru/docs/http/configuring_https_servers.html here in the certificate chain section there is info on how to do this.

V
Volodymyr Godyak, 2016-06-02
@wmgodyak

For mobile, you need to make a chain of certificates and transfer it as a certificate.
It is described in detail here: nginx.org/ru/docs/http/configuring_https_servers.html
Example:

cd /etc/nginx/ssl
ll
 > domain.ca-bundle domain.crt  domain.csr  domain.rsa

cat domain.crt domain.ca-bundle >  domain.chained.crt
ll
> domain.ca-bundle domain.crt  domain.csr  domain.rsa domain.chained.crt

My nginx config
server {
        listen 80 default_server;

        listen 443 ssl;

        root /var/www/domain/frontend/www;
        index index.php index.html index.htm;

        # Make site accessible from http://localhost/
        server_name domain.com;

        ssl_certificate /etc/nginx/ssl/domain.chained.crt;
        ssl_certificate_key /etc/nginx/ssl/domain.rsa;

        ssl_session_timeout 5m;
        ssl_protocols SSLv3 TLSv1;
        ssl_ciphers ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv3:+EXP;
        ssl_prefer_server_ciphers on;

......

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question