Estou tentando configurar um HTTPS, mas não funciona e não sei o que está errado.
Estes são os passos que segui:
-
Gerei um certificado .pem
(certificado + cadeia) com letsencrypt , usando o próximo comando:
sudo -H ./letsencrypt-auto certonly --server https://acme-v01.api.letsencrypt.org/directory
A resposta é assim:
IMPORTANT NOTES:
- Congratulations! Your certificate and chain have been saved at
/etc/letsencrypt/live/xxxx.com/fullchain.pem. Your cert
will expire on 2016-03-07. To obtain a new version of the
certificate in the future, simply run Let's Encrypt again.
- If like Let's Encrypt, please consider supporting our work by:
Donating to ISRG / Let's Encrypt: https://letsencrypt.org/donate
Donating to EFF: https://eff.org/donate-le
-
Eu gerou uma chave privada
sudo openssl req -new -x509 -days 365 -nodes -out /etc/letsencrypt/live/xxxx.com/fullchain.pem -keyout /etc/letsencrypt/live/xxxx.com/fullchain.key
Aqui abaixo, colei a resposta:
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]:US
State or Province Name (full name) [Some-State]:xxxx
Locality Name (eg, city) []:xxxx
Organization Name (eg, company) [Internet Widgits Pty Ltd]:xxxx
Organizational Unit Name (eg, section) []:xxxx.com
Common Name (e.g. server FQDN or YOUR name) []:test
Email Address []:[email protected]
-
Eu verifiquei que a chave retorna o valor correto que defini na última etapa:
sudo openssl x509 -in /etc/letsencrypt/live/xxxx.com/fullchain.pem -noout -subject
Aqui abaixo, colei a resposta:
subject= /C=US/ST=xxxx/L=xxxx/O=xxxx/OU=xxxx.com/CN=test/
[email protected]
-
Eu configurei um novo host virtual que copio aqui abaixo:
<VirtualHost *:443>
ServerAdmin [email protected]
DocumentRoot /var/www/html/xxx1/public
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
ServerName xxxx.com
SSLEngine on
SSLCertificateFile /etc/letsencrypt/live/xxxx.com/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/xxxx.com/fullchain.key
<FilesMatch "\.(cgi|shtml|phtml|php)$">
SSLOptions +StdEnvVars
</FilesMatch>
<Directory /usr/lib/cgi-bin>
SSLOptions +StdEnvVars
</Directory>
BrowserMatch "MSIE [2-6]" \
nokeepalive ssl-unclean-shutdown \
downgrade-1.0 force-response-1.0
BrowserMatch "MSIE [17-9]" ssl-unclean-shutdown
</VirtualHost>
-
Eu abri a porta 443 no meu /etc/apache2/ports.conf
.
Depois de todos esses passos, acabei de fazer sudo service apache2 restart
, mas o console está aguardando até eu chegar:
Job for apache2.service failed because the control process exited with error code. See "systemctl status apache2.service" and "journalctl -xe" for details.
e quando eu depurar com journalctl -xe
, o resultado é o seguinte:
-- Unit apache2.service has begun starting up.
Dec 08 19:12:20 devXxxx apache2[21637]: * Starting web server apache2
Dec 08 19:12:20 devXxxx apache2[21637]: AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 100.114.32.17. Set the 'ServerName' directive globally to suppress this mes
Dec 08 19:12:20 devXxxx apache2[21637]: (98)Address already in use: AH00072: make_sock: could not bind to address [::]:443
Dec 08 19:12:29 devXxxx sudo[21613]: pam_unix(sudo:session): session closed for user root
Dec 08 19:12:29 devXxxx polkitd(authority=local)[996]: Unregistered Authentication Agent for unix-process:21628:9475994 (system bus name :1.109, object path /org/freedesktop/PolicyKit1/AuthenticationAgent, loca
Dec 08 19:12:40 devXxxx apache2[21637]: *
Dec 08 19:12:40 devXxxx apache2[21637]: * The apache2 instance did not start within 20 seconds. Please read the log files to discover problems
Dec 08 19:12:40 devXxxx systemd[1]: apache2.service: Control process exited, code=exited status=1
Dec 08 19:12:40 devXxxx systemd[1]: Failed to start LSB: Apache2 web server.
-- Subject: Unit apache2.service has failed
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit apache2.service has failed.
Depois de ver esses 20 segundos que o apache está tentando carregar, decidi testar o certificado conforme detalho:
-
Verificando apenas 1 certificado:
sudo ln -s /etc/letsencrypt/live/xxxx.com/fullchain.pem
sudo openssl x509 -há sem -no / em /etc/letsencrypt/live/xxxx.com/fullchain.pem .0
-
Verificando se o certificado funciona:
openssl verify -CApath f6361f65.0
mas surpresa, não .... o terminal continua tentando se conectar sem resposta.
Alguém pode me ajudar?
Obrigado por conselhos.