Nextcloud does not accept the lets-encrypt certificate

hello I’m using the nextcloud version Nextcloud 18.0.4 installed with debian

I use these commands to activate the certificate and work with HTTPS

sudo snap install nextcloud

sudo nextcloud.occ config: system: get trusted_domains

sudo nextcloud.occ config: system: set trusted_domains 1 --value = DOMAIN

sudo nextcloud.occ config: system: get trusted_domains

apt-get install ufw

/ sbin / ufw allow 80,443 / tcp

sudo nextcloud.enable-https lets-encrypt

after the commands still not working

I checked what happens more precisely, you can change the domain that was before nextcloud.com to nextcloud.com.br for example
and after performing this procedure above or the next cloud does not access with https, checking the certificate that is still registered in the old one.

How do I delete this old one and leave it for the new one?

From what I see above, I’m not sure you actually got a certificate.

Let’s encrypt has a guide here. I recommend using Certbot as they describe in the guide.

You need to specify all the domains the key should be valid for, and add the path to your key in the virtual hosts files in Apache if that’s what you’re using.

Your virtual hosts file should go in /etc/apache2/sites-available/ and should look something like this:

<IfModule mod_ssl.c>
    <VirtualHost _default_:443>

        ServerAdmin your@email.address

        # Use your machine and domain name
        ServerName www.your.domain
        ServerAlias anothermachine.your.domain

        # Use your path to Nextcloud
        DocumentRoot /var/www/html/nextcloud

        SSLEngine on
        # Path to key files
        SSLCertificateFile /etc/letsencrypt/live/your.domain/fullchain.pem
        SSLCertificateKeyFile /etc/letsencrypt/live/your.domain/privkey.pem

        # From the Nectcloud install instructions
        <Directory /var/www/nextcloud/>
            Require all granted
            AllowOverride All
            Options FollowSymLinks MultiViews

            <IfModule mod_dav.c>
                Dav off
            </IfModule>

        </Directory>

    </VirtualHost>
</IfModule>

And to activate the virtual host file you use

sudo a2ensite yourvirtualhostfilename

Ferdinand is correct, it doesn’t look like you actually have a Let’s Encrypt certificate. You need to use a Let’s Encrypt client (e.g. Certbot) to acquire the certificate. You can configure the certificate in your webserver yourself, or rely on the client to configure it for you.

Regardless, a TLS/HTTPS certificate needs to be configured in your webserver (e.g. Apache or NginX), you don’t do it through occ.

Do you actually have your own domain? Your comment referencing nextcloud.com and nextcloud.com.br wasn’t very clear.

Hello, I haven’t tried what the colleague suggests doing the test.
But just to try to make the situation clearer
My nextcloud, before using the Domain nextcloud.novapc.com.br, Problem with the dominant domain that you change for nextcloudnpc.dyndns.info.
the Domain discovers that it is working and is not entering the nextcloud, but it is not present in HTTPS, and when I click to see the certificate in the browser it still appears nextclud.novapc.com.br

When I try to perform the procedure that ferdinand went through, I can’t find the apache2 folder, my installation was via SNAP, with debian 9

Certificates are specific to a domain. You can’t keep using a certificate meant for nextcloud.novapc.com.br if you’ve changed your domain to nextcloudnpc.dyndns.info. You need to get a new certificate.

I’d still check out Let’s Encrypt. Their forum might be able to give you some guidance.

Sorry, I’m on FreeBSD, I don’t know where Apache files are on Debian.

The main Apache configuration file is httpd.conf, and it will have lines in it starting with “Include”. For example:
Include etc/apache24/extra/httpd-vhosts.conf

That line will “include” the information in the extra file httpd-vhosts.conf. If you can find httpd.conf, it will tell you where to look for the other files.

Good luck!

What @DarkSteve said, and also - if you installed with SNAP I think you’re in some kind of container, or virtual environment, so the Apache configuration folder may be somewhere else. It should be somewhere though, as Apache can’t work without its configuration files.

Maybe this is useful?