SSL 一直等待响应

SSL 一直等待响应

我正在尝试配置 HTTPS,但它不起作用,而且我真的不知道哪里出了问题。

以下是我遵循的步骤:

  1. 我已经生成了一个.pem证书(证书+链)letsencrypt,使用以下命令:

    sudo -H ./letsencrypt-auto certonly --server https://acme-v01.api.letsencrypt.org/directory

响应如下:

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
  1. 我已经生成了私钥

    sudo openssl req -new -x509 -days 365 -nodes -out /etc/letsencrypt/live/xxxx.com/fullchain.pem -keyout /etc/letsencrypt/live/xxxx.com/fullchain.key

下面我粘贴了回复:

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]
  1. 我已经检查过该键是否返回了我在上一步中设置的正确值:

    sudo openssl x509 -in /etc/letsencrypt/live/xxxx.com/fullchain.pem -noout -subject

下面我粘贴了回复:

subject= /C=US/ST=xxxx/L=xxxx/O=xxxx/OU=xxxx.com/CN=test/
[email protected]
  1. 我已经设置了一个新的虚拟主机,将其复制到下面:

    <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>
    
  2. 我已经在我的 上打开了 443 端口/etc/apache2/ports.conf

完成所有这些步骤后,我只需执行此操作sudo service apache2 restart,但控制台仍在等待我获得:

Job for apache2.service failed because the control process exited with error code. See "systemctl status apache2.service" and "journalctl -xe" for details.

当我调试它时,journalctl -xe结果如下:

-- 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.

在观察了 apache 尝试加载的这 20 秒后,我决定测试证书,如下所示:

  1. 检查是否仅有 1 个证书:

    sudo ln -s /etc/letsencrypt/live/xxxx.com/fullchain.pemsudo openssl x509 -hash -noout -in /etc/letsencrypt/live/xxxx.com/fullchain.pem.0

  2. 验证证书是否有效:

    openssl verify -CApath f6361f65.0

但令人惊讶的是,它没有......终端一直尝试连接但没有响应。

有人能帮我吗?

谢谢建议。

答案1

首先,看起来好像某些东西已经绑定到端口443

12 月 08 日 19:12:20 devXxxx apache2[21637]: (98)地址已在使用中: AH00072: make_sock: 无法绑定到地址 [::]:443 D

接下来,使用 Lets Encrypt,您不需要设置自己的私钥,脚本会为您生成一个(除非您手动生成自己的 CSR)。

letsencrypt-auto脚本完成时,您的证书目录中应该有 4 个文件。

  • cert.pem- 这是您的证书。Apache 中SSLCertificateFile应该指向此文件。
  • privkey.pem- 这是您的私钥。请保密。Apache 中SSLCertificateKeyFile应指向此文件。
  • chain.pem- 这是建立信任的证书链。在 Apache 中,您可以指向SSLCertificateChainFile此文件。
  • fullchain.pemcert.pem- 这是和的组合chain.pem,因此它是您的证书及其完整的信任链。在 Apache 中指向SSLCACertificateFile此文件。

让我们加密文档

答案2

对于 letsencypt,此命令对我有用,无需停止服务器

./letsencrypt-auto certonly --webroot -w /websitedir -d www.domain.com

完成 nginx 的此过程后,您就可以链接证书了。

ln -s privkey.pem /etc/ssl/domain.key
ln -s fullchain.pem /etc/ssl/domain.crt

相关内容