DNS Error while trying enabling HTTPS on Apache with Let’s Encrypt on Linux Mint 21.3

Please fill out the fields below so we can help you better. Note: you must provide your domain name to get help. Domain names for issued certificates are all made public in Certificate Transparency logs (e.g. crt.sh | example.com), so withholding your domain name here does not increase secrecy, but only makes it harder for us to provide help.

My domain is: "http://www.infoalquiler.com.ar/"

I ran this command:

sudo certbot --apache --agree-tos --redirect --uir --hsts --staple-ocsp --must-staple -v

It produced this output:

Saving debug log to /var/log/letsencrypt/letsencrypt.log
Plugins selected: Authenticator apache, Installer apache

Which names would you like to activate HTTPS for?
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1: infoalquiler.com.ar
2: www.infoalquiler.com.ar
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Select the appropriate numbers separated by commas and/or spaces, or leave input
blank to select all options shown (Enter 'c' to cancel): 
Requesting a certificate for infoalquiler.com.ar and www.infoalquiler.com.ar
Performing the following challenges:
http-01 challenge for infoalquiler.com.ar
http-01 challenge for www.infoalquiler.com.ar
Waiting for verification...
Challenge failed for domain infoalquiler.com.ar
Challenge failed for domain www.infoalquiler.com.ar
http-01 challenge for infoalquiler.com.ar
http-01 challenge for www.infoalquiler.com.ar

Certbot failed to authenticate some domains (authenticator: apache). The Certificate Authority reported these problems:
  Domain: infoalquiler.com.ar
  Type:   dns
  Detail: DNS problem: SERVFAIL looking up A for infoalquiler.com.ar - the domain's nameservers may be malfunctioning; DNS problem: SERVFAIL looking up AAAA for infoalquiler.com.ar - the domain's nameservers may be malfunctioning

  Domain: www.infoalquiler.com.ar
  Type:   dns
  Detail: DNS problem: SERVFAIL looking up A for www.infoalquiler.com.ar - the domain's nameservers may be malfunctioning; DNS problem: SERVFAIL looking up AAAA for www.infoalquiler.com.ar - the domain's nameservers may be malfunctioning

Hint: The Certificate Authority failed to verify the temporary Apache configuration changes made by Certbot. Ensure that the listed domains point to this Apache server and that it is accessible from the internet.

Cleaning up challenges
Some challenges have failed.
Ask for help or search for solutions at https://community.letsencrypt.org. See the logfile /var/log/letsencrypt/letsencrypt.log or re-run Certbot with -v for more details.

My web server is (include version):

Server version: Apache/2.4.52 (Ubuntu)
Server built: 2023-10-26T13:44:44

The operating system my web server runs on is (include version):
Linux Mint 21.3 (Virginia) MATE Edition

My hosting provider, if applicable, is: Local Deployment

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):

certbot 1.21.0

The issue is this one: I've followed this tutorial to enable properly an HTTPS connection on my Apache Server, to some domains setted up by making VirtualHosts.

So on, I've followed the steps provided by this tutorial:
(Properly Enable HTTPS on Apache with Let's Encrypt on Ubuntu)

Also this one, with a similar content:
(How To Secure Apache with Let's Encrypt on Ubuntu 22.04 | DigitalOcean)

Since I was getting that mentioned DNS error while trying that, I've looked for help to configure properly the DNS server on my system, using Bind9 for that purpose.

I've followed this tutorials for doing that:
(https://ubuntu.com/server/docs/service-domain-name-service-dns)
(https://www.youtube.com/watch?v=aTb9JeKp5TA)
(Video tutorial in Spanish)

After lots of attemps, I've could properly set up the bind service, having this output in my terminal:

leandro@leandro-Lenovo-B50-10:~$ sudo systemctl restart bind9.service
leandro@leandro-Lenovo-B50-10:~$ sudo systemctl status bind9.service
● named.service - BIND Domain Name Server
     Loaded: loaded (/lib/systemd/system/named.service; enabled; vendor preset: enabled)
     Active: active (running) since Mon 2024-03-18 04:25:38 -03; 4s ago
       Docs: man:named(8)
    Process: 15095 ExecStart=/usr/sbin/named $OPTIONS (code=exited, status=0/SUCCESS)
   Main PID: 15096 (named)
      Tasks: 6 (limit: 9228)
     Memory: 5.8M
        CPU: 106ms
     CGroup: /system.slice/named.service
             └─15096 /usr/sbin/named -u bind

mar 18 04:25:38 leandro-Lenovo-B50-10 named[15096]: network unreachable resolving './NS/IN': 2001:503:ba3e::2:30#53
mar 18 04:25:38 leandro-Lenovo-B50-10 named[15096]: network unreachable resolving './NS/IN': 2001:500:12::d0d#53
mar 18 04:25:38 leandro-Lenovo-B50-10 named[15096]: network unreachable resolving './NS/IN': 2001:500:2::c#53
mar 18 04:25:38 leandro-Lenovo-B50-10 named[15096]: network unreachable resolving './NS/IN': 2001:500:9f::42#53
mar 18 04:25:38 leandro-Lenovo-B50-10 named[15096]: network unreachable resolving './NS/IN': 2001:dc3::35#53
mar 18 04:25:38 leandro-Lenovo-B50-10 named[15096]: network unreachable resolving './NS/IN': 2001:503:c27::2:30#53
mar 18 04:25:38 leandro-Lenovo-B50-10 named[15096]: network unreachable resolving './NS/IN': 2001:500:1::53#53
mar 18 04:25:38 leandro-Lenovo-B50-10 named[15096]: network unreachable resolving './NS/IN': 2001:500:2f::f#53
mar 18 04:25:38 leandro-Lenovo-B50-10 named[15096]: managed-keys-zone: Key 20326 for zone . is now trusted (acceptance timer complete)
mar 18 04:25:38 leandro-Lenovo-B50-10 named[15096]: resolver priming query complete: success

I've ran this command with this output:

leandro@leandro-Lenovo-B50-10:~$ nslookup www.infoalquiler.com.ar 127.0.0.1
Server:		127.0.0.1
Address:	127.0.0.1#53

www.infoalquiler.com.ar	canonical name = infoalquiler.com.ar.
Name:	infoalquiler.com.ar
Address: 127.0.0.1
Name:	infoalquiler.com.ar
Address: ::1

In the Bind log file I got this:

client @0x7f5d4c1e9108 127.0.0.1#60629 (www.infoalquiler.com.ar): query: www.infoalquiler.com.ar IN A + (127.0.0.1)
client @0x7f5d4c1e9108 127.0.0.1#44262 (infoalquiler.com.ar): query: infoalquiler.com.ar IN AAAA + (127.0.0.1)

Also, ran this with this output:

leandro@leandro-Lenovo-B50-10:~$ dig infoalquiler.com.ar CAA

; <<>> DiG 9.18.18-0ubuntu0.22.04.2-Ubuntu <<>> infoalquiler.com.ar CAA
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: SERVFAIL, id: 45259
;; flags: qr rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 65494
;; QUESTION SECTION:
;infoalquiler.com.ar.		IN	CAA

;; Query time: 288 msec
;; SERVER: 127.0.0.53#53(127.0.0.53) (UDP)
;; WHEN: Mon Mar 18 02:34:06 -03 2024
;; MSG SIZE  rcvd: 48

However, despite after lots of attemps, I'm still getting the same DNS error.

Here's my most relevant Bind9 config files at "/etc/bind":

"named.conf":

include "/etc/bind/named.conf.options";
include "/etc/bind/named.conf.local";
include "/etc/bind/named.conf.default-zones";

"named.conf.options":

options {
	directory "/var/cache/bind";

	// If there is a firewall between you and nameservers you want
	// to talk to, you may need to fix the firewall to allow multiple
	// ports to talk.  See http://www.kb.cert.org/vuls/id/800113

	// If your ISP provided one or more IP addresses for stable 
	// nameservers, you probably want to use them as forwarders.  
	// Uncomment the following block, and insert the addresses replacing 
	// the all-0's placeholder.

	 forwarders {
	 	127.0.0.53;
	 };

	//========================================================================
	// If BIND logs error messages about the root key being expired,
	// you will need to update your keys.  See https://www.isc.org/bind-keys
	//========================================================================
	dnssec-validation auto;

    listen-on { any; };
	listen-on-v6 { any; };
    allow-query { any; };
};

"named.conf.local":

//
// Do any local configuration here
//

// Consider adding the 1918 zones here, if they are not used in your
// organization
//include "/etc/bind/zones.rfc1918";

zone "infoalquiler.com.ar" {
    type master;
    file "/etc/bind/db.infoalquiler";
};


zone "127.0.0.in-addr.arpa" {
   type master;
   file "/etc/bind/db.127.0.0.in-addr.arpa";
};

logging {
    channel query.log {
        file "/var/log/named/query.log";
        severity debug 3;
    };
    category queries { query.log; };
};

"db.infoalquiler":

;
; BIND data file for local loopback interface
;
$TTL	604800
@	IN	SOA	infoalquiler.com.ar. root.infoalquiler.com.ar. (
			     20		; Serial
			 604800		; Refresh
			  86400		; Retry
			2419200		; Expire
			 604800 )	; Negative Cache TTL
;
@   	IN	NS	infoalquiler.com.ar.
@	    IN	A	127.0.0.1
mail	IN	A	127.0.0.1
www	IN	CNAME	infoalquiler.com.ar.
;@	    IN	MX  10	127.0.0.1
cisco   IN	A	127.0.0.1
ns	    IN	A	127.0.0.1
@	    IN	AAAA	::1
infoalquiler.com.ar. IN CAA 0 issue "letsencrypt.org"

"db.127.0.0.in-addr.arpa":

;
; BIND reverse data file for local loopback interface
;
$TTL	604800
@	IN	SOA	infoalquiler.com.ar. root.infoalquiler.com.ar.  (
			     20		; Serial
			 604800		; Refresh
			  86400		; Retry
			2419200		; Expire
			 604800 )	; Negative Cache TTL
;
@	IN	NS	infoalquiler.com.ar.
10	IN	PTR	infoalquiler.com.ar.

My Apache config files at "/etc/apache2": are like this:

"apache2.conf" (It has just the default content, except for this line):

...
# Global configuration
#
ServerName 127.0.0.1
...

"ports.conf":

# If you just change the port or add more ports here, you will likely also
# have to change the VirtualHost statement in
# /etc/apache2/sites-enabled/000-default.conf

Listen 80

<IfModule ssl_module>
	Listen 443
</IfModule>

<IfModule mod_gnutls.c>
	Listen 443
</IfModule>

# vim: syntax=apache ts=4 sw=4 sts=4 sr noet

At "/etc/apache2/sites-available" I've got:

"000-default.conf":

<VirtualHost *:80>
	# The ServerName directive sets the request scheme, hostname and port that
	# the server uses to identify itself. This is used when creating
	# redirection URLs. In the context of virtual hosts, the ServerName
	# specifies what hostname must appear in the request's Host: header to
	# match this virtual host. For the default virtual host (this file) this
	# value is not decisive as it is used as a last resort host regardless.
	# However, you must set it for any further virtual host explicitly.
	#ServerName www.example.com

	ServerAdmin webmaster@localhost
	DocumentRoot /var/www/html

	# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
	# error, crit, alert, emerg.
	# It is also possible to configure the loglevel for particular
	# modules, e.g.
	#LogLevel info ssl:warn

	ErrorLog ${APACHE_LOG_DIR}/error.log
	CustomLog ${APACHE_LOG_DIR}/access.log combined

	# For most configuration files from conf-available/, which are
	# enabled or disabled at a global level, it is possible to
	# include a line for only one particular virtual host. For example the
	# following line enables the CGI configuration for this host only
	# after it has been globally disabled with "a2disconf".
	#Include conf-available/serve-cgi-bin.conf
</VirtualHost>

# vim: syntax=apache ts=4 sw=4 sts=4 sr noet

"infoalquiler.conf":

<VirtualHost *:80>

    ServerAdmin leandrocaplan@gmail.com
    ServerName infoalquiler.com.ar
    ServerAlias www.infoalquiler.com.ar

    DocumentRoot /var/www/html/infoalquiler/public

    <Directory />
            Options FollowSymLinks
            AllowOverride None
    </Directory>
    <Directory /var/www/html/infoalquiler>
        Options -Indexes +FollowSymLinks +MultiViews
        AllowOverride All
        Require all granted
    </Directory>

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined

</VirtualHost>

"default-ssl.conf":

<IfModule mod_ssl.c>
	<VirtualHost _default_:443>
		ServerAdmin webmaster@localhost

		DocumentRoot /var/www/html

		# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
		# error, crit, alert, emerg.
		# It is also possible to configure the loglevel for particular
		# modules, e.g.
		#LogLevel info ssl:warn

		ErrorLog ${APACHE_LOG_DIR}/error.log
		CustomLog ${APACHE_LOG_DIR}/access.log combined

		# For most configuration files from conf-available/, which are
		# enabled or disabled at a global level, it is possible to
		# include a line for only one particular virtual host. For example the
		# following line enables the CGI configuration for this host only
		# after it has been globally disabled with "a2disconf".
		#Include conf-available/serve-cgi-bin.conf

		#   SSL Engine Switch:
		#   Enable/Disable SSL for this virtual host.
		SSLEngine on

		#   A self-signed (snakeoil) certificate can be created by installing
		#   the ssl-cert package. See
		#   /usr/share/doc/apache2/README.Debian.gz for more info.
		#   If both key and certificate are stored in the same file, only the
		#   SSLCertificateFile directive is needed.
		SSLCertificateFile	/etc/ssl/certs/ssl-cert-snakeoil.pem
		SSLCertificateKeyFile /etc/ssl/private/ssl-cert-snakeoil.key

		#   Server Certificate Chain:
		#   Point SSLCertificateChainFile at a file containing the
		#   concatenation of PEM encoded CA certificates which form the
		#   certificate chain for the server certificate. Alternatively
		#   the referenced file can be the same as SSLCertificateFile
		#   when the CA certificates are directly appended to the server
		#   certificate for convinience.
		#SSLCertificateChainFile /etc/apache2/ssl.crt/server-ca.crt

		#   Certificate Authority (CA):
		#   Set the CA certificate verification path where to find CA
		#   certificates for client authentication or alternatively one
		#   huge file containing all of them (file must be PEM encoded)
		#   Note: Inside SSLCACertificatePath you need hash symlinks
		#		 to point to the certificate files. Use the provided
		#		 Makefile to update the hash symlinks after changes.
		#SSLCACertificatePath /etc/ssl/certs/
		#SSLCACertificateFile /etc/apache2/ssl.crt/ca-bundle.crt

		#   Certificate Revocation Lists (CRL):
		#   Set the CA revocation path where to find CA CRLs for client
		#   authentication or alternatively one huge file containing all
		#   of them (file must be PEM encoded)
		#   Note: Inside SSLCARevocationPath you need hash symlinks
		#		 to point to the certificate files. Use the provided
		#		 Makefile to update the hash symlinks after changes.
		#SSLCARevocationPath /etc/apache2/ssl.crl/
		#SSLCARevocationFile /etc/apache2/ssl.crl/ca-bundle.crl

		#   Client Authentication (Type):
		#   Client certificate verification type and depth.  Types are
		#   none, optional, require and optional_no_ca.  Depth is a
		#   number which specifies how deeply to verify the certificate
		#   issuer chain before deciding the certificate is not valid.
		#SSLVerifyClient require
		#SSLVerifyDepth  10

		#   SSL Engine Options:
		#   Set various options for the SSL engine.
		#   o FakeBasicAuth:
		#	 Translate the client X.509 into a Basic Authorisation.  This means that
		#	 the standard Auth/DBMAuth methods can be used for access control.  The
		#	 user name is the `one line' version of the client's X.509 certificate.
		#	 Note that no password is obtained from the user. Every entry in the user
		#	 file needs this password: `xxj31ZMTZzkVA'.
		#   o ExportCertData:
		#	 This exports two additional environment variables: SSL_CLIENT_CERT and
		#	 SSL_SERVER_CERT. These contain the PEM-encoded certificates of the
		#	 server (always existing) and the client (only existing when client
		#	 authentication is used). This can be used to import the certificates
		#	 into CGI scripts.
		#   o StdEnvVars:
		#	 This exports the standard SSL/TLS related `SSL_*' environment variables.
		#	 Per default this exportation is switched off for performance reasons,
		#	 because the extraction step is an expensive operation and is usually
		#	 useless for serving static content. So one usually enables the
		#	 exportation for CGI and SSI requests only.
		#   o OptRenegotiate:
		#	 This enables optimized SSL connection renegotiation handling when SSL
		#	 directives are used in per-directory context.
		#SSLOptions +FakeBasicAuth +ExportCertData +StrictRequire
		<FilesMatch "\.(cgi|shtml|phtml|php)$">
				SSLOptions +StdEnvVars
		</FilesMatch>
		<Directory /usr/lib/cgi-bin>
				SSLOptions +StdEnvVars
		</Directory>

		#   SSL Protocol Adjustments:
		#   The safe and default but still SSL/TLS standard compliant shutdown
		#   approach is that mod_ssl sends the close notify alert but doesn't wait for
		#   the close notify alert from client. When you need a different shutdown
		#   approach you can use one of the following variables:
		#   o ssl-unclean-shutdown:
		#	 This forces an unclean shutdown when the connection is closed, i.e. no
		#	 SSL close notify alert is send or allowed to received.  This violates
		#	 the SSL/TLS standard but is needed for some brain-dead browsers. Use
		#	 this when you receive I/O errors because of the standard approach where
		#	 mod_ssl sends the close notify alert.
		#   o ssl-accurate-shutdown:
		#	 This forces an accurate shutdown when the connection is closed, i.e. a
		#	 SSL close notify alert is send and mod_ssl waits for the close notify
		#	 alert of the client. This is 100% SSL/TLS standard compliant, but in
		#	 practice often causes hanging connections with brain-dead browsers. Use
		#	 this only for browsers where you know that their SSL implementation
		#	 works correctly.
		#   Notice: Most problems of broken clients are also related to the HTTP
		#   keep-alive facility, so you usually additionally want to disable
		#   keep-alive for those clients, too. Use variable "nokeepalive" for this.
		#   Similarly, one has to force some clients to use HTTP/1.0 to workaround
		#   their broken HTTP/1.1 implementation. Use variables "downgrade-1.0" and
		#   "force-response-1.0" for this.
		# BrowserMatch "MSIE [2-6]" \
		#		nokeepalive ssl-unclean-shutdown \
		#		downgrade-1.0 force-response-1.0

	</VirtualHost>
</IfModule>

# vim: syntax=apache ts=4 sw=4 sts=4 sr noet

EDIT: I only have "000-default.conf" and "infoalquiler.conf" in my "/sites-enabled" directory as symlinks

As a detail, I've also ran the following command with the following output:

leandro@leandro-Lenovo-B50-10:~$ cat /etc/resolv.conf
# This is /run/systemd/resolve/stub-resolv.conf managed by man:systemd-resolved(8).
# Do not edit.
#
# This file might be symlinked as /etc/resolv.conf. If you're looking at
# /etc/resolv.conf and seeing this text, you have followed the symlink.
#
# This is a dynamic resolv.conf file for connecting local clients to the
# internal DNS stub resolver of systemd-resolved. This file lists all
# configured search domains.
#
# Run "resolvectl status" to see details about the uplink DNS servers
# currently in use.
#
# Third party programs should typically not access this file directly, but only
# through the symlink at /etc/resolv.conf. To manage man:resolv.conf(5) in a
# different way, replace this symlink by a static file or a different symlink.
#
# See man:systemd-resolved.service(8) for details about the supported modes of
# operation for /etc/resolv.conf.

nameserver 127.0.0.53
options edns0 trust-ad
search fibertel.com.ar

I wonder if this result has something to do when setting the "fowarders" field on my "named.conf.options", I may be doing something wrong there

I've also checked this issues at the community, but didn't really helped:
(Help! , The DNS problem)
(DNS problem: SERVFAIL looking up A)

I can properly access my domain defined on my VirtualHost Apache files like this:

However, I'm not being able to set up properly an HTTPS configuration to run it on a "https://..." like URL, so than annoying security warning ("No seguro" in spanish) at the address bar would just go away.

Any idea of what's could be going wrong? Any more information needed?

Thanks a lot!
Leandro

EDIT 2:

My "/etc/hosts" file is like this:

127.0.0.1	localhost
127.0.1.1	leandro-Lenovo-B50-10
127.0.0.1   www.infoalquiler.com.ar

# The following lines are desirable for IPv6 capable hosts
::1     ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters

Your DNS Server is not responding to requests from the public internet. It results in SERVFAIL for any query. Not just from Let's Encrypt but anyone. You need a working DNS server to get a certificate from a public cert authority like LE.

The only example that worked was from your own local network. Do you want access from the public internet or just private connections?

See the same SERVFAIL using this google DNS test tool
https://dns.google/query?name=www.infoalquiler.com.ar&rr_type=A&ecs=
And this one does queries like Let's Encrypt does
https://unboundtest.com

4 Likes

At the moment, I'm just trying to set up the domain just for running in my own computer, that's it, in localhost.
I've tried to set up a DNS server in my system by using Bind9, as Ubuntu documentation says: "the most common program used for maintaining a name server on Linux".
So then, there it must be lot of things I'm overlooking, since I'm really inexperienced in this area.
I've shared then, the content of my BIND config files, so then perhaps somebody can become aware of my errors, and so on, help me to find a solution.
I'm now just trying to access my domains defined by Apache's VirtualHost using HTTPS, instead of simple HTTP.
For the future, I understand that there's lots of things I should learn to properly set up a HTTP server, and also a DNS server if I plan to make a domain available for the public internet instead of just my own computer, and there are lots of docs I should read for achieving that purpose.
However, I now just would be satisfied by accessing a domain created by a VirtualHost by using HTTPS, being those quoted tutorial links in my post aiming to achieve just that.
Any docs suggested by any member of the community, it really be quite welcome and appreciated.
If useful, I can share here the result of querying my domain (www.infoalquiler.com.ar) in https://unboundtest.com/, from my own machine.

Thanks a lot
Leandro

1 Like

Here is what ICANN reports about the domain name

1 Like

And the 2 name servers responses are REFUSED

$ nslookup -q=any infoalquiler.com.ar ns1.donweb.com.
Server:         ns1.donweb.com.
Address:        200.58.112.193#53

** server can't find infoalquiler.com.ar: REFUSED
$ nslookup -q=any infoalquiler.com.ar ns2.donweb.com.
Server:         ns2.donweb.com.
Address:        200.58.112.101#53

** server can't find infoalquiler.com.ar: REFUSED

And here Hardenize Report: infoalquiler.com.ar gets the same results

1 Like

Let’s Encrypt offers Domain Validation (DV) certificates.

Thus you need to own and have control over the Domain Name (or have a subdomain under an existing domain name, for example pointed to your server by your employer or school) you wish to obtain a certificate for, from an ICANN Accredited Registrar.

For Let’s Encrypt to issue a Domain Validation (DV) certificate Domain Validation must happen
and it is a CA/Browser Forum Baseline Requirement.

Let's Encrypt uses Multi-Perspective Validation Improves Domain Validation Security - Let's Encrypt

Since these are Domain Validation (DV) certificates the Domain Name System (DNS) is used extensively in the validation process as well a allowing us to assist here on Let's Encrypt community.
DNS Queries need to give consistent results from any location on the Internet, all your authoritative DNS Servers for the Domain need to also give consistent results as well.

2 Likes

You won't be able to get a Let's Encrypt cert for "localhost". And, you won't be able to get an LE cert (or one from any public Certificate Authority) without your DNS working on the public internet.

The LinuxBabe link you showed expects you to already have a working DNS server to use. You don't have to setup your own. You could use Cloudflare for example. That is a popular and free high quality DNS server system. It and Let's Encrypt work well together. (https://cloudflare.com) An existing DNS service is probably a good choice until your expertise allows you to run your own.

For just local operation there are some suggestions below

5 Likes

That's was just what I needed, thank you very much!

I finally could access my VirtualHost domain by HTTPS like this:

The proper commands I've run in the terminal where these (after trying lot of stuff, but here's what it worked):

leandro@leandro-Lenovo-B50-10:~$ sudo mkdir /etc/apache2/ssl


leandro@leandro-Lenovo-B50-10:~$ cd /etc/apache2/ssl


leandro@leandro-Lenovo-B50-10:/etc/apache2/ssl$ sudo openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/apache2/ssl/apache.key -out /etc/apache2/ssl/apache.crt -addext 'subjectAltName=DNS:infoalquiler.com.ar,DNS:www.infoalquiler.com.ar'
...+..........+..+.......+........+...+...+.+..................+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*....+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*....+.....+....+......+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
.......+......+..+......+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*.....+...+.........+.+...+.........+..+....+......+.....+......+............+......+.+...+...+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*...+..+.............+..+.+.....+............+........................+....+......+...+..+......+.......+...+..............+...+......+.......+..+...+...+.+...+..+.............+........+.........+.+.....+.......+.....+.+......+...+.................+....+......+......+.....+...+.+...+........+...+.+.........+.........+...+............+...........+.......+...............+.........+.....+.........+.......+........+.....................+.+..+.+......+........+.+..+...+.+...+.....+.+.....+.+......+...+.....+.+.......................+...+.............+..+........................+................+..+......+.+...+.....+......+.+......+...+............+..+......+..........+............+.........+...+..+......+...............+....+.....+................+.....+.......+...........+...............+.........+.+......+.....+...+..........+...+..+.+..+.......+............+..............+.+.....+.+.........+...+...+...+.....+....+...+..+.+......+...+........+...+.+...+.....+......+......................+........+.......+..+...+.......+...+........+....+..+...+...+.........+....+......+.....................+...+............+.....+....+.....+..........+.....+.............+..+.+...+..............+.+.....+.+......+.........+.....+.+...+...........+......+...+.+.....+.........+....+..+.+.................+.+.........+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-----
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [AU]:AR
State or Province Name (full name) [Some-State]:BA
Locality Name (eg, city) []:Buenos Aires
Organization Name (eg, company) [Internet Widgits Pty Ltd]:Leandro Caplan
Organizational Unit Name (eg, section) []:
Common Name (e.g. server FQDN or YOUR name) []:Leandro Caplan
Email Address []:leandrocaplan@gmail.com


leandro@leandro-Lenovo-B50-10:/etc/apache2/ssl$ openssl x509 -noout -text -in apache.crt
Certificate:
    Data:
        Version: 3 (0x2)
        Serial Number:
            39:0a:c9:50:d3:bc:a4:ca:9d:0d:62:10:e5:dd:e2:a5:82:80:26:44
        Signature Algorithm: sha256WithRSAEncryption
        Issuer: C = AR, ST = BA, L = Buenos Aires, O = Leandro Caplan, CN = Leandro Caplan, emailAddress = leandrocaplan@gmail.com
        Validity
            Not Before: Mar 18 19:38:35 2024 GMT
            Not After : Mar 18 19:38:35 2025 GMT
        Subject: C = AR, ST = BA, L = Buenos Aires, O = Leandro Caplan, CN = Leandro Caplan, emailAddress = leandrocaplan@gmail.com
        Subject Public Key Info:
            Public Key Algorithm: rsaEncryption
                Public-Key: (2048 bit)
                Modulus:
                    00:af:ca:5e:1d:4d:cb:9f:02:06:c1:d8:07:2d:15:
                    8e:f4:61:ed:b0:11:6d:ff:a1:d1:c0:70:98:49:5f:
                    09:ff:2e:44:c9:3b:37:02:b2:57:b0:09:ee:15:2e:
                    cc:dc:a1:49:6c:08:e0:dc:d5:df:e1:48:94:d6:b7:
                    78:49:f9:33:82:0a:58:8b:4d:50:91:45:9e:df:ea:
                    d6:76:49:58:c2:b5:97:2f:1d:8a:b2:13:de:d9:72:
                    43:78:b0:b2:1c:d1:1a:0b:e5:65:d3:46:3e:be:ad:
                    c2:28:48:cd:1b:62:4c:68:22:c5:07:2d:03:2f:13:
                    7d:c8:04:c0:9f:14:7d:0d:37:0a:fc:d4:66:e4:b7:
                    4d:a7:a9:1f:3c:5d:45:df:d0:12:e5:bb:31:54:b7:
                    0a:ea:c3:1c:ea:e5:b6:d8:d9:68:0e:f7:54:39:59:
                    37:c6:db:88:ab:6c:ac:ea:88:92:7b:24:84:a1:41:
                    a4:2a:89:28:39:9c:4d:4c:2b:8f:79:0b:5c:e5:d9:
                    a0:4f:b9:47:82:2b:55:f5:87:76:2e:f9:46:a8:b1:
                    1f:58:9a:93:8c:e5:76:aa:18:94:64:33:63:d7:68:
                    5e:f2:91:ef:bb:42:d4:7f:69:49:04:89:3e:60:2a:
                    63:9a:ad:ce:81:cc:dc:06:ff:7c:94:7d:ee:81:25:
                    e5:45
                Exponent: 65537 (0x10001)
        X509v3 extensions:
            X509v3 Subject Key Identifier: 
                6C:46:B9:9A:CC:21:71:3B:DA:0D:B9:CF:BF:5C:F1:38:5F:09:1F:81
            X509v3 Authority Key Identifier: 
                6C:46:B9:9A:CC:21:71:3B:DA:0D:B9:CF:BF:5C:F1:38:5F:09:1F:81
            X509v3 Basic Constraints: critical
                CA:TRUE
            X509v3 Subject Alternative Name: 
                DNS:infoalquiler.com.ar, DNS:www.infoalquiler.com.ar
    Signature Algorithm: sha256WithRSAEncryption
    Signature Value:
        84:26:1a:3b:3e:c3:8f:cc:41:e8:03:6d:21:b9:c1:a4:3a:80:
        6c:58:b6:98:04:71:43:2b:da:26:63:54:cf:fd:6e:61:8c:cf:
        41:0f:91:74:4c:1c:04:3b:2b:0f:3a:eb:a4:ff:65:b2:6a:35:
        80:32:96:8c:1b:c4:31:42:59:99:1a:dd:0a:2a:d8:4c:6e:83:
        cb:23:e3:b4:98:cf:e7:d5:95:c5:10:de:2a:bf:62:68:25:9a:
        70:99:81:83:0e:3a:79:86:bd:58:b1:f3:54:e1:36:f4:de:f8:
        8b:02:3a:a8:d2:c2:fa:85:2f:c4:27:c4:82:e4:34:5d:68:52:
        5b:e1:7a:29:12:2b:74:f9:4d:fc:11:bc:20:01:07:c2:ba:c9:
        82:46:cd:74:1c:9e:05:bc:a3:88:fa:01:44:ad:42:66:03:f9:
        d5:3c:ba:5d:3d:e3:fd:73:36:2a:70:74:87:ff:e7:28:a4:92:
        bd:ac:96:65:a3:4e:86:ae:e6:cc:04:0b:12:be:ee:a8:01:78:
        ff:6d:69:2e:1f:88:c8:29:0f:d5:34:f6:89:bf:cc:1b:a3:61:
        30:5f:ab:fd:78:1d:a5:31:5a:31:cb:b9:f7:ec:39:1f:19:2b:
        ca:f8:ba:d4:c5:ed:cf:42:76:d3:61:59:c8:3c:99:7f:fe:87:
        58:35:65:28


leandro@leandro-Lenovo-B50-10:/etc/apache2/ssl$ sudo chown www-data:www-data apache.key apache.crt


leandro@leandro-Lenovo-B50-10:/etc/apache2/ssl$ sudo chmod 775 apache*


leandro@leandro-Lenovo-B50-10:/etc/apache2/ssl$ sudo a2enmod ssl
Considering dependency setenvif for ssl:
Module setenvif already enabled
Considering dependency mime for ssl:
Module mime already enabled
Considering dependency socache_shmcb for ssl:
Module socache_shmcb already enabled
Module ssl already enabled


leandro@leandro-Lenovo-B50-10:~$ sudo systemctl restart apache2

My "infoalquiler.conf" VirtualHost file kept like this:

<VirtualHost *:443>

    SSLEngine on
    SSLCertificateFile /etc/apache2/ssl/apache.crt
    SSLCertificateKeyFile /etc/apache2/ssl/apache.key
    ServerAdmin leandrocaplan@gmail.com
    ServerName infoalquiler.com.ar
    ServerAlias www.infoalquiler.com.ar

    DocumentRoot /var/www/html/infoalquiler/public

    <Directory />
            Options FollowSymLinks
            AllowOverride None
    </Directory>
    <Directory /var/www/html/infoalquiler>
        Options -Indexes +FollowSymLinks +MultiViews
        AllowOverride All
        Require all granted
    </Directory>

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined

</VirtualHost>

Finally, the steps followed in Chrome navigator to manually set up the trusted certificates where these (is the Spanish version of Chrome):

I first had a issue since I was wrongly importing certificate in tab "Your certificates" instead of "Authorities".

Then I was having an issue since Chrome shown this security issue:

"Your security certificate does not specify the Subject Alternative Name extension"

Solved that by adding to the command:

sudo openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/apache2/ssl/apache.key -out /etc/apache2/ssl/apache.crt

The option:

-addext 'subjectAltName=DNS:infoalquiler.com.ar,DNS:www.infoalquiler.com.ar'

Also dealing a little bit with the ownership and permissions of certificate and key files.

So then, the main sites I've consulted that helped to solve my issue (in addition to the article you provided to me) were these ones:

Tested my app for a while and everything seems to work fine! Really thank you!

My best regards
Leandro

3 Likes

@leandrocaplan be aware you can see the website, but no-one else can (that is not bad or wrong if that is what you desire).

https://www.ssllabs.com/ssltest/analyze.html?d=www.infoalquiler.com.ar

I know that. I was just attempting to run my website with HTTPS in that domain just in my own computer. At the moment I'm not trying to make it available to public internet.
If in the future I plan to achieve that, I understand that the procedure might be quite different and maybe much more extensive.

Thank you anyway for the notice.

4 Likes

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