Nginx failed to open privkey.pem


#1

Hi am a newbe. Show the following error after nginx reload/restart to enable ssl. my nginx configuration is

server {
listen 443 default;

ssl on;

    ssl_certificate /etc/letsencrypt/live/DomainName/fullchain.pem;
  ssl_certificate_key /etc/letsencrypt/live/DomainName/privkey.key;
server_name  callforamerica.com;

 root /var/www/DomainName/public;
try_files $uri/index.html $uri @unicorn;


}
I check file is present in “/etc/letsencrypt/live/DomainName/” location

SSL_CTX_use_PrivateKey_file("/etc/letsencrypt/live/domainName/privkey.key") failed (SSL: error:02001002:system library:fopen:No such file or directory:fopen(’/etc/letsencrypt/live/domainName/privkey.key’,‘r’) error:20074002:BIO routines:FILE_CTRL:system lib error:140B0002:SSL routines:SSL_CTX_use_PrivateKey_file:system lib)
could u please help me.


#2

Hi shah

go to the directory

cd /etc/letsencrypt/live/DomainName/
type nano privkey.key or cat privekey.key and paste the first and last line in this post (do not paste the whole contents as this is your key)
you should see have something like

----BEGIN PRIVATE KEY-----
MIIJQgIBADANBgkqhkiG9w0BAQEFAASCCSwwggkoAgEAAoICAQCk2RdZWms+oguE


-----END PRIVATE KEY-----

type openssl rsa -in privateKey.key -check

the last command might not work if openssl is not installed

need to make sure the key actually exists and has useful content (i.e. a correctly formatted key)


#3

Hi,
I am using privkey.pem file not privekey.key. I install nginx as not a root user.
when I open file using

$ sudo nano /etc/letsencrypt/live/DomainName/privkey.pem

its show something like this:

----BEGIN PRIVATE KEY-----
MIIJQgIBADANBgkqhkiG9w0BAQEFAASCCSwwggkoAgEAAoICAQCk2RdZWms+oguE


-----END PRIVATE KEY-----

and if I type the 2nd command which u suggest vy using following command

$ openssl rsa -in privkey.pem -check
The output error is following
============O/P Error========================
Error opening Private Key privkey.pem
116838640711328:error:0200100D:system library:fopen:Permission denied:bss_file.c:398:fopen(‘privkey.pem’,‘r’)
116838640711328:error:20074002:BIO routines:FILE_CTRL:system lib:bss_file.c:400:
unable to load Private Key

but If I type command using “sudo” then show the

-----BEGIN RSA PRIVATE KEY-----
MIIEpQIBAAKCAQEA3uyzq152Errbk7B7GMXHO8A1PfD/KWgjYMeLEZb/zvE+CRNQ


.-----END RSA PRIVATE KEY-----

thanks


#4

Hi sorry its working. Its my mistake. I am using
ssl_certificate_key /etc/letsencrypt/live/DomainName/privkey.key;

Instead of
ssl_certificate_key /etc/letsencrypt/live/DomainName/privkey.pem;

its my typing mistake . there be .pem not .key.

Thanks


#5

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.