Renew certificate for mail

if I enter where it says view certificate
issued for: imap.estudioines.com
issued by: Lets Encrypt Authority X3
Valid from: 23/11/2017 to 21/02/2018

that error also appears on other devices: iphone, ipad

Ah. I guess that means you access the imap server via a different domain name, but it’s using the same certificate. You seem to already have a valid certificate for the imap domain name (assuming it’s not literally mydomain.com in the output from certbot certificates) so you should probably just configure the imap server to use that instead of the smtp certificate.

EDIT: or rather, vice versa. I’m tired. It’s after 2am here :slight_smile: you should probably configure the smtp server… etc. I should get some sleep lol

You could combine the domain names SMTP and IMAP on one cert and use that cert for both services.

1 Like

Thanks for your time! Ok, then will try configure smtp, ut i dont have idea how

Mmmm, how do it? Never try to combine domain names,

Try:
certbot certonly -d smtp.mydomain --webroot-path /path/to/smtp/files -d imap.mydomain --webroot-path /path/to/imap/files

replace domains with your actual domains
replace /path/… with your actual paths

sorry for my ignorance, but what path are we talking about? I can not understand … and I do not want to make everything work badly then

If your “certonly” command succeeds, certbot gets a cert and changes nothing.
If your “certonly” command fails, certbot gets nothing and changes nothing.

The paths would be as specified in the your “webserver” software.
Wherever the “root” path for each is located in your system.
Again, if you try and it fails nothing bad happens*
*=other than it logs that as a failed attempt…
So you might want to “try” with --dry-run or -staging until you get the command and paths correct.

Sorry for delay,

certbot certonly --dry-run

Saving debug log to /var/log/letsencrypt/letsencrypt.log

How would you like to authenticate with the ACME CA?

1: Apache Web Server plugin - Beta (apache)
2: Place files in webroot directory (webroot)
3: Spin up a temporary webserver (standalone)

Select the appropriate number [1-3] then [enter] (press ‘c’ to cancel):2

Starting new HTTPS connection (1): acme-staging.api.letsencrypt.org
Please enter in your domain name(s) (comma and/or space separated) (Enter 'c’
to cancel):imap.estudioines.com
Cert not due for renewal, but simulating renewal for dry run
Renewing an existing certificate
Performing the following challenges:
http-01 challenge for imap.mydomain.com

Select the webroot for imap.mydomain.com:

1: Enter a new webroot

Press 1 [enter] to confirm the selection (press ‘c’ to cancel): 1

Input the webroot for imap.mydomain.com: (Enter ‘c’ to cancel):???


??? does not exist or is not a directory

Input the webroot for imap.mydomain.com: (Enter ‘c’ to cancel):c

Select the webroot for imap.mydomain.com:

1: Enter a new webroot

Press 1 [enter] to confirm the selection (press ‘c’ to cancel): c
Cleaning up challenges
Every requested domain must have a webroot when using the webroot plugin.

Then:

1: Enter a new webroot

Press 1 [enter] to confirm the selection (press ‘c’ to cancel): 1
Input the webroot for imap.mydomain.com: (Enter ‘c’ to cancel):/etc/letsencrypt/live/smtp.mydomain.com
Waiting for verification…
Cleaning up challenges
Failed authorization procedure. imap.mydomain.com (http-01): urn:acme:error:unauthorized :: The client lacks sufficient authorization :: Invalid response from http://imap.estudioines.com/.well-known/acme-challenge/L7FOjBofI99-olKbdvHNpuJV27eCu0pVgoQOpeseC-4: "

404 Not Found

Not Found

<p"

IMPORTANT NOTES:


I do not understand why the webroot command.
The path /var/ www/html is empty, there are no configuration files. All certificates are renewed for 84 days and the Dovecot configuration (an extract from it) has the following:

ssl_cert = </etc/letsencrypt/live/imap.mydomain.com/fullchain.pem
ssl_key = </etc/letsencrypt/live/imap.mydomain.com/privkey.pem

beyond that microsoft outlook and other mail applications for end users give the same error (for more all certificates, smtp, imap, mail … are updated):
“The server you are connected to is using a security certificate that can not verify” “the target principal name is incorrect”

I’m pretty lost, you know excuse me. but the configuration of the server is in operation, the only thing we can not remove the error in the applications that send and receive mails. Times ago my co-worker has made the renovation in such a way that this does not happen.
If you need configuration files of postfix or dovecot or any other file tell me and I will expose here such configurations.

Neither of those are correct.
You need to give the location of the root folder for the site.
Start by finding which service is bound to port 80.
Then find the configuration files for that web service.

http://letsencrypt.readthedocs.io/en/latest/using.html#webroot

Ok,

#fuser -n tcp 80
80/tcp: 813 14648 14650 14651 14652 14653 14654 14767 16182 16183

/# ps x | grep 813
813 ? Ss 0:08 /usr/sbin/apache2 -k start
16625 pts/0 S+ 0:00 grep 813

Others process id have the same result (for example 16182)
ps x | grep 16182
16641 pts/0 S+ 0:00 grep 16182

path /var/www/html is empty, no conf file inside or other file

show:
/usr/sbin/apachectl -V

/usr/sbin/apachectl -V

Server version: Apache/2.4.10 (Debian)
Server built: Jul 20 2016 07:07:13
Server’s Module Magic Number: 20120211:37
Server loaded: APR 1.5.1, APR-UTIL 1.5.4
Compiled using: APR 1.5.1, APR-UTIL 1.5.4
Architecture: 32-bit
Server MPM: prefork
threaded: no
forked: yes (variable process count)
Server compiled with…
-D APR_HAS_SENDFILE
-D APR_HAS_MMAP
-D APR_HAVE_IPV6 (IPv4-mapped addresses enabled)
-D APR_USE_SYSVSEM_SERIALIZE
-D APR_USE_PTHREAD_SERIALIZE
-D SINGLE_LISTEN_UNSERIALIZED_ACCEPT
-D APR_HAS_OTHER_CHILD
-D AP_HAVE_RELIABLE_PIPED_LOGS
-D DYNAMIC_MODULE_LIMIT=256
-D HTTPD_ROOT="/etc/apache2"
-D SUEXEC_BIN="/usr/lib/apache2/suexec"
-D DEFAULT_PIDLOG="/var/run/apache2.pid"
-D DEFAULT_SCOREBOARD=“logs/apache_runtime_status”
-D DEFAULT_ERRORLOG=“logs/error_log”
-D AP_TYPES_CONFIG_FILE=“mime.types”
-D SERVER_CONFIG_FILE=“apache2.conf”

Sorry te path no is empty, have inside index.html file

For other way:

/etc/apache2/sites-enabled# ls
000-default.conf default-ssl.conf

#cat default-ssl.conf

ServerAdmin webmaster@localhost
            DocumentRoot /var/www/html

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


            #   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
            # MSIE 7 and newer should be able to use keepalive
            BrowserMatch "MSIE [17-9]" ssl-unclean-shutdown

    </VirtualHost>

cat 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

start by showing:
/etc/apache2/apache2.conf

cat apache2.conf

This is the main Apache server configuration file. It contains the

configuration directives that give the server its instructions.

See http://httpd.apache.org/docs/2.4/ for detailed information about

the directives and /usr/share/doc/apache2/README.Debian about Debian specific

hints.

Summary of how the Apache 2 configuration works in Debian:

The Apache 2 web server configuration in Debian is quite different to

upstream’s suggested way to configure the web server. This is because Debian’s

default Apache2 installation attempts to make adding and removing modules,

virtual hosts, and extra configuration directives as flexible as possible, in

order to make automating the changes and administering the server as easy as

possible.

It is split into several files forming the configuration hierarchy outlined

below, all located in the /etc/apache2/ directory:

/etc/apache2/

|-- apache2.conf

| `-- ports.conf

|-- mods-enabled

| |-- *.load

| `-- *.conf

|-- conf-enabled

| `-- *.conf

`-- sites-enabled

`-- *.conf

* apache2.conf is the main configuration file (this file). It puts the pieces

together by including all remaining configuration files when starting up the

web server.

* ports.conf is always included from the main configuration file. It is

supposed to determine listening ports for incoming connections which can be

customized anytime.

* Configuration files in the mods-enabled/, conf-enabled/ and sites-enabled/

directories contain particular configuration snippets which manage modules,

global configuration fragments, or virtual host configurations,

respectively.

They are activated by symlinking available configuration files from their

respective *-available/ counterparts. These should be managed by using our

helpers a2enmod/a2dismod, a2ensite/a2dissite and a2enconf/a2disconf. See

their respective man pages for detailed information.

* The binary is called apache2. Due to the use of environment variables, in

the default configuration, apache2 needs to be started/stopped with

/etc/init.d/apache2 or apache2ctl. Calling /usr/bin/apache2 directly will not

work with the default configuration.

Global configuration

ServerRoot: The top of the directory tree under which the server’s

configuration, error, and log files are kept.

NOTE! If you intend to place this on an NFS (or otherwise network)

mounted filesystem then please read the Mutex documentation (available

at URL:http://httpd.apache.org/docs/2.4/mod/core.html#mutex);

you will save yourself a lot of trouble.

Do NOT add a slash at the end of the directory path.

#ServerRoot “/etc/apache2”

The accept serialization lock file MUST BE STORED ON A LOCAL DISK.

Mutex file:${APACHE_LOCK_DIR} default

PidFile: The file in which the server should record its process

identification number when it starts.

This needs to be set in /etc/apache2/envvars

PidFile ${APACHE_PID_FILE}

Timeout: The number of seconds before receives and sends time out.

Timeout 300

KeepAlive: Whether or not to allow persistent connections (more than

one request per connection). Set to “Off” to deactivate.

KeepAlive On

MaxKeepAliveRequests: The maximum number of requests to allow

during a persistent connection. Set to 0 to allow an unlimited amount.

We recommend you leave this number high, for maximum performance.

MaxKeepAliveRequests 100

KeepAliveTimeout: Number of seconds to wait for the next request from the

same client on the same connection.

KeepAliveTimeout 5

These need to be set in /etc/apache2/envvars

User ${APACHE_RUN_USER}
Group ${APACHE_RUN_GROUP}

HostnameLookups: Log the names of clients or just their IP addresses

e.g., www.apache.org (on) or 204.62.129.132 (off).

The default is off because it’d be overall better for the net if people

had to knowingly turn this feature on, since enabling it means that

each client request will result in AT LEAST one lookup request to the

nameserver.

HostnameLookups Off

ErrorLog: The location of the error log file.

If you do not specify an ErrorLog directive within a

container, error messages relating to that virtual host will be

logged here. If you do define an error logfile for a

container, that host’s errors will be logged there and not here.

ErrorLog ${APACHE_LOG_DIR}/error.log

LogLevel: Control the severity of messages logged to the error_log.

Available values: trace8, …, trace1, debug, info, notice, warn,

error, crit, alert, emerg.

It is also possible to configure the log level for particular modules, e.g.

“LogLevel info ssl:warn”

LogLevel warn

Include module configuration:

IncludeOptional mods-enabled/.load
IncludeOptional mods-enabled/
.conf

Include list of ports to listen on

Include ports.conf

Sets the default security model of the Apache2 HTTPD server. It does

not allow access to the root filesystem outside of /usr/share and /var/www.

The former is used by web applications packaged in Debian,

the latter may be used for local directories served by the web server. If

your system is serving content from a sub-directory in /srv you must allow

access here, or in any related virtual host.

Options FollowSymLinks AllowOverride None Require all denied

<Directory /usr/share>
AllowOverride None
Require all granted

<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted

#<Directory /srv/>

Options Indexes FollowSymLinks

AllowOverride None

Require all granted

#

AccessFileName: The name of the file to look for in each directory

for additional configuration directives. See also the AllowOverride

directive.

AccessFileName .htaccess

The following lines prevent .htaccess and .htpasswd files from being

viewed by Web clients.

<FilesMatch “^.ht”>
Require all denied

The following directives define some format nicknames for use with

a CustomLog directive.

These deviate from the Common Log Format definitions in that they use %O

(the actual bytes sent including headers) instead of %b (the size of the

requested file), because the latter makes it impossible to detect partial

requests.

Note that the use of %{X-Forwarded-For}i instead of %h is not recommended.

Use mod_remoteip instead.

LogFormat “%v:%p %h %l %u %t “%r” %>s %O “%{Referer}i” “%{User-Agent}i”” vhost_combined
LogFormat “%h %l %u %t “%r” %>s %O “%{Referer}i” “%{User-Agent}i”” combined
LogFormat “%h %l %u %t “%r” %>s %O” common
LogFormat “%{Referer}i -> %U” referer
LogFormat “%{User-agent}i” agent

Include of directories ignores editors’ and dpkg’s backup files,

see README.Debian for details.

Include generic snippets of statements

IncludeOptional conf-enabled/*.conf

Include the virtual host configurations:

IncludeOptional sites-enabled/*.conf

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

OK.
show all of:
/etc/apache2/sites-enabled/000-default.conf

cat 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

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

/etc/apache2/sites-enabled/default-ssl.conf shows:
DocumentRoot /var/www/html

try
grep -i root /etc/apache2/sites-enabled/*

grep -i root /etc/apache2/sites-enabled/*

/etc/apache2/sites-enabled/000-default.conf: DocumentRoot /var/www/html
/etc/apache2/sites-enabled/analaura5.conf: DocumentRoot /var/www/analaura5/httpdocs/
/etc/apache2/sites-enabled/default-ssl.conf: DocumentRoot /var/www/html

OK there it is:
DocumentRoot /var/www/html
create the path and test file:
mkdir /var/www/html/.well-known
mkdir /var/www/html/.well-known/acme-challenge
echo test > /var/www/html/.well-known/acme-challenge/test.txt
then try accessing it from the outside:
http://your.sitename/.well-known/acme-challenge/test.txt

it seems that http is being redirected to https…
So we need to ensure Apache is handling the HTTPS requests.
Try
netstat -pant | grep 443