Skip to content

Instantly share code, notes, and snippets.

@singhabhinav
Last active April 14, 2023 12:44
Show Gist options
  • Save singhabhinav/132b8196abac026b43fa to your computer and use it in GitHub Desktop.
Save singhabhinav/132b8196abac026b43fa to your computer and use it in GitHub Desktop.
Install SSL certificate in Nginx (Using .crt & .ca-bundle certificate files)
Step 1 - Create .crt file
cat domainname.crt domainname.ca-bundle > domainname-ssl-bundle.crt
Step 2-
Add lines for ssl_certificate in nginx configuration
server {
listen 80 default_server;
listen [::]:80 default_server ipv6only=on;
listen 443 ssl;
ssl_certificate /etc/ssl/certs/domainname-ssl-bundle.crt;
ssl_certificate_key /etc/ssl/private/domainname.key;
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;
}
@BananaNeil
Copy link

I have .crt file and .ca-Bundle. but when i configure it according to all above steps it is giving me errot : cannot load certificate key : PEM_read_bio_PrivateKey() failed (SSL: error:0909006C:PEM routines:get_name:no start line:Expecting: ANY PRIVATE KEY) I don't have Key file i have only two files mention above. So please let me know what is wrong.

The private key should have been created when you generated your CSR.

@danielkwok21
Copy link

I have .crt file and .ca-Bundle. but when i configure it according to all above steps it is giving me errot : cannot load certificate key : PEM_read_bio_PrivateKey() failed (SSL: error:0909006C:PEM routines:get_name:no start line:Expecting: ANY PRIVATE KEY) I don't have Key file i have only two files mention above. So please let me know what is wrong.

Hi, this helped me - https://stackoverflow.com/a/31736141

TLDR
Mine was ----BEGIN RSA PRIVATE KEY----- vs -----BEGIN RSA PRIVATE KEY-----, it was missing a - character.
Took me an hour to notice the problem.

Hope it helps.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment