Accidently Deleted SSL Certifiacte

I was trying to delete my certificate on my website and get a new one. I deleted the certbot that was already installed and tried to reinstall it again and when I go to check to see the certificate existence it keeps telling me that sudo ls /etc/letsencrypt/live no such file or directory exists.

My domain is:https://filehb.tech/

I ran this command: sudo certbot --nginx

It produced this output:ln: missing file operand
Try 'ln --help' for more information.
root@Omnihost:~# sudo certbot --nginx
Saving debug log to /var/log/letsencrypt/letsencrypt.log
Error while running nginx -c /etc/nginx/nginx.conf -t.

nginx: [emerg] cannot load certificate "/etc/letsencrypt/live/filehb.tech/fullchain.pem": BIO_new_file() failed (SSL: error:80000002:system library::No such file or directory:calling fopen(/etc/letsencrypt/live/filehb.tech/fullchain.pem, r) error:10000080:BIO routines::no such file)
nginx: configuration file /etc/nginx/nginx.conf test failed

My web server is (include version): Nginx

The operating system my web server runs on is (include version): Ubunto 22.04.3

My hosting provider, if applicable, is:

I can login to a root shell on my machine (yes or no, or I don't know): Yes

I'm using a control panel to manage my site (no, or provide the name and version of the control panel): No

The version of my client is (e.g. output of certbot --version or certbot-auto --version if you're using Certbot): Don't know

The problem you are seeing is that certbot can't update the linked file references because the source file doesn't exist anymore, and nginx can't load because your current configuration in etc/nginx/nginx.conf references a file that doesn't exist any more (or a link to that missing file).

I'm not a certbot expert but I would suggest running certbot delete to clean up the broken certificate then run certbot again to get an install a new certificate. If the problem persists you may need to edit your nginx config to remove/update references to the missing certificate files.

For more info refer to User Guide — Certbot 2.10.0 documentation

1 Like

I tried deleting certbot and redownloading it same issue. How do I edit my nginx config? This is my first time really doing this

If this is for a business I would suggest getting advice from a local web development company to help as there is a reasonable amount of stuff to learn.

1 Like

This is for a school project

Use your favorite text editing tool to edit the file /etc/nginx/nginx.conf.

3 Likes

Cool, I'm not the best person to teach you how to use linux I'm afraid. Personally I use nano to edit files on Ubuntu but you generally need to look at the nginx config file and understand what the configuration is telling it to do. The location of your nginx config file is plainly stated in your original post.

Take your time and break the problem into smaller parts, I would suggest you start by trying sudo certbot delete --cert-name filehb.tech to cleanup your invalid certbot config, unless that option isn't working, then start again with a new certificate configuration.

3 Likes

This is my configuration file what exactly am I supposed to do

worker_processes auto;
pid /run/nginx.pid;
include /etc/nginx/modules-enabled/*.conf;

events {
       worker_connections 768;
       # multi_accept on;
}

http {

       ##
       # Basic Settings
       ##

       sendfile on;
       tcp_nopush on;
       types_hash_max_size 2048;
       # server_tokens off;

       # server_names_hash_bucket_size 64;
       # server_name_in_redirect off;

       include /etc/nginx/mime.types;
       default_type application/octet-stream;

       ##
       # SSL Settings
       ##

       ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3; # Dropping SSLv3, ref: POODLE
       ssl_prefer_server_ciphers on;

       ##
       # Logging Settings
       ##

       access_log /var/log/nginx/access.log;
       error_log /var/log/nginx/error.log;

       ##
       # Gzip Settings
       ##

       gzip on;

       # gzip_vary on;
       # gzip_proxied any;
       # gzip_comp_level 6;
       # gzip_buffers 16 8k;
       # gzip_http_version 1.1;
       # gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;

       ##
       # Virtual Host Configs
       ##

       include /etc/nginx/conf.d/*.conf;
       include /etc/nginx/sites-enabled/*;
}


#mail {
#       # See sample authentication script at:
#       # http://wiki.nginx.org/ImapAuthenticateWithApachePhpScript
#
#       # auth_http localhost/auth.php;
#       # pop3_capabilities "TOP" "USER";
#       # imap_capabilities "IMAP4rev1" "UIDPLUS";
#
#       server {
#               listen     localhost:110;
#               protocol   pop3;
#               proxy      on;
#       }
#
#       server {
#               listen     localhost:143;
#               protocol   imap;
#               proxy      on;
#       }

Did you happen to create a site there? If so, Certbot may have edited it when you previously enabled HTTPS. Can you check whether there are any configuration files present in that directory?

2 Likes

/etc/nginx/sites-enabled/default

# You should look at the following URL's in order to grasp a solid understanding
# of Nginx configuration files in order to fully unleash the power of Nginx.
# https://www.nginx.com/resources/wiki/start/
# https://www.nginx.com/resources/wiki/start/topics/tutorials/config_pitfalls/
# https://wiki.debian.org/Nginx/DirectoryStructure
#
# In most cases, administrators will remove this file from sites-enabled/ and
# leave it as reference inside of sites-available where it will continue to be
# updated by the nginx packaging team.
#
# This file will automatically load configuration files provided by other
# applications, such as Drupal or Wordpress. These applications will be made
# available underneath a path with that package name, such as /drupal8.
#
# Please see /usr/share/doc/nginx-doc/examples/ for more detailed examples.
##

# Default server configuration
#
server {
       listen 80 default_server;
       listen [::]:80 default_server;

       # SSL configuration
       #
       # listen 443 ssl default_server;
       # listen [::]:443 ssl default_server;
       #
       # Note: You should disable gzip for SSL traffic.
       # See: https://bugs.debian.org/773332
       #
       # Read up on ssl_ciphers to ensure a secure configuration.
       # See: https://bugs.debian.org/765782
       #
       # Self signed certs generated by the ssl-cert package
       # Don't use them in a production server!
       #
       # include snippets/snakeoil.conf;

       root /var/www/html;

       # Add index.php to the list if you are using PHP
       index index.html index.htm index.nginx-debian.html;

       server_name _;

       location / {
               # First attempt to serve request as file, then
               # as directory, then fall back to displaying a 404.
               try_files $uri $uri/ =404;
       }

       # pass PHP scripts to FastCGI server
       #
       #location ~ \.php$ {
       #       include snippets/fastcgi-php.conf;
       #
       #       # With php-fpm (or other unix sockets):
       #       fastcgi_pass unix:/run/php/php7.4-fpm.sock;
       #       # With php-cgi (or other tcp sockets):
       #       fastcgi_pass 127.0.0.1:9000;
       #}

       # deny access to .htaccess files, if Apache's document root
       # concurs with nginx's one
       #
       #location ~ /\.ht {
       #       deny all;
       #}
}


# Virtual Host configuration for example.com
#
# You can move that to a different file under sites-available/ and symlink that
# to sites-enabled/ to enable it.
#
#server {
#       listen 80;
#       listen [::]:80;
#
#       server_name example.com;
#
#       root /var/www/example.com;
#       index index.html;
#
#       location / {
#               try_files $uri $uri/ =404;
#       }
#}

server {

       # SSL configuration
       #
       # listen 443 ssl default_server;
       # listen [::]:443 ssl default_server;
       #
       # Note: You should disable gzip for SSL traffic.
       # See: https://bugs.debian.org/773332
       #
       # Read up on ssl_ciphers to ensure a secure configuration.
       # See: https://bugs.debian.org/765782
       #
       # Self signed certs generated by the ssl-cert package
       # Don't use them in a production server!
       #
       # include snippets/snakeoil.conf;

       root /var/www/html;

       # Add index.php to the list if you are using PHP
       index index.html index.htm index.nginx-debian.html;
   server_name www.filehb.tech filehb.tech; # managed by Certbot


       location / {
               # First attempt to serve request as file, then
               # as directory, then fall back to displaying a 404.
               try_files $uri $uri/ =404;
       }

       # pass PHP scripts to FastCGI server
       #
       #location ~ \.php$ {
       #       include snippets/fastcgi-php.conf;
       #
       #       # With php-fpm (or other unix sockets):
       #       fastcgi_pass unix:/run/php/php7.4-fpm.sock;
       #       # With php-cgi (or other tcp sockets):
       #       fastcgi_pass 127.0.0.1:9000;
       #}

       # deny access to .htaccess files, if Apache's document root
       # concurs with nginx's one
       #
       #location ~ /\.ht {
       #       deny all;
       #}


   listen [::]:443 ssl ipv6only=on; # managed by Certbot
   listen 443 ssl; # managed by Certbot
   ssl_certificate /etc/letsencrypt/live/filehb.tech/fullchain.pem; # managed by Certbot
   ssl_certificate_key /etc/letsencrypt/live/filehb.tech/privkey.pem; # managed by Certbot
   include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
   ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot



}
server {
   if ($host = www.filehb.tech) {
       return 301 https://$host$request_uri;
   } # managed by Certbot


   if ($host = filehb.tech) {
       return 301 https://$host$request_uri;
   } # managed by Certbot
  
   listen 80 ;
       listen [::]:80 ;
   server_name www.filehb.tech filehb.tech;
   return 404; # managed by Certbot




}

Tip: when pasting configuration or code to the forum use three backticks ``` before and after the code block so that it gets formatted properly [you can also go back and edit your existing posts to fix formatting problems, this helps people read your response and make it more likely they can help you]

2 Likes

As this is for a school project, my advice would be to walk through the entire nginx configuration file, line by line, and learn to understand every single directive: what does it do? Usually using the nginx documentation works fine for this. And yes, this might take some time, but in the end, you'll learn a lot.

Next is to use everything you've learned and look at the exact error produced by Certbot. And figure out WHY Certbot is complaining. Hint: it's not just Certbot that's complaining, your nginx is complaining too on its own.

4 Likes

I don't have time and would prefer guidance on how to fix this if possible. After the issue is fixed I would like to go back and learn everything without any worries

@DepressionCherry your Ports 80 & 443 are CLOSED, I suggest Opening them.

$ nmap -Pn -p80,443 filehb.tech
Starting Nmap 7.80 ( https://nmap.org ) at 2024-04-16 20:06 UTC
Nmap scan report for filehb.tech (143.198.153.174)
Host is up (0.025s latency).

PORT    STATE  SERVICE
80/tcp  closed http
443/tcp closed https

Nmap done: 1 IP address (1 host up) scanned in 0.20 seconds
1 Like

It looks like its already open I run the command and it shows this
root@Omnihost:~# sudo ufw status verbose
Status: active
Logging: on (low)
Default: deny (incoming), allow (outgoing), disabled (routed)
New profiles: skip

To Action From


80,443/tcp (Nginx Full) ALLOW IN Anywhere
22/tcp (OpenSSH) ALLOW IN Anywhere
443 ALLOW IN Anywhere
5000 ALLOW IN Anywhere
5002 ALLOW IN Anywhere
80,443/tcp (Nginx Full (v6)) ALLOW IN Anywhere (v6)
22/tcp (OpenSSH (v6)) ALLOW IN Anywhere (v6)
443 (v6) ALLOW IN Anywhere (v6)
5000 (v6) ALLOW IN Anywhere (v6)
5002 (v6) ALLOW IN Anywhere (v6)

@DepressionCherry

From around the world shows "Connection refused". :frowning:
http Permanent link to this check report
https Permanent link to this check report

2 Likes

For general nginx information you might find nginx documentation and https://forum.nginx.org/ helpful.

1 Like

You don't think it has something to do with this error
'## root@Omnihost:~# tail /var/log/letsencrypt/letsencrypt.log 2024-04-16 19:52:16,307:DEBUG:certbot._internal.plugins.selection:Single candidate plugin: * nginx Description: Nginx Web Server plugin Interfaces: Authenticator, Installer, Plugin Entry point: EntryPoint(name='nginx', value='certbot_nginx._internal.configurator:NginxConfigurator', group='certbot.plugins') Initialized: <certbot_nginx._internal.configurator.NginxConfigurator object at 0x7fa7dfb84be0> Prep: Error while running nginx -c /etc/nginx/nginx.conf -t. nginx: [emerg] cannot load certificate "/etc/letsencrypt/live/filehb.tech/fullchain.pem": BIO_new_file() failed (SSL: error:80000002:system library::No such file or directory:calling fopen(/etc/letsencrypt/live/filehb.tech/fullchain.pem, r) error:10000080:BIO routines::no such file) nginx: configuration file /etc/nginx/nginx.conf test failed

Like does, please show the output of sudo nginx -T (that is an uppercase T)

1 Like

root@Omnihost:~# sudo nginx -T
nginx: [emerg] cannot load certificate "/etc/letsencrypt/live/filehb.tech/fullchain.pem": BIO_new_file() failed (SSL: error:80000002:system library::No such file or directory:calling fopen(/etc/letsencrypt/live/filehb.tech/fullchain.pem, r) error:10000080:BIO routines::no such file)
nginx: configuration file /etc/nginx/nginx.conf test failed