SSL连接不能使用公共IP地址

编辑:问题解决了,它确实是服务器的防火墙阻挡端口443。一切正在工作

我试图在ubuntu上运行的apache服务器上安装一个自签名的SSL证书。 我允许使用SSL模块,编辑default-ssl.conf文件,并将创build自签名证书时将ServerName作为CommonName放置的IP地址。 我编辑了文件中.crt和.key文件的位置。 然后我启用了default-ssl.conf文件并重新启动了apache。

我每次检查5次,所以我很确定我没有犯错。

当我尝试访问https://ip_address它不会加载。 我检查了443端口是开放的。 有没有办法看到问题的位置? 我只是不知道下一步该怎么做。 我通过SSH访问服务器。

这是我目前的默认-ssl.conf:

 <IfModule mod_ssl.c> <VirtualHost *:443> ServerAdmin [email protected] ServerName 54.82.28.171:443 DocumentRoot /var/www <Directory /> Options FollowSymLinksAllowOverride None Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch Order allow,deny Allow from all </Directory> ErrorLog ${APACHE_LOG_DIR}/error.log # Possible values include: debug, info, notice, warn, error, crit, # alert, emerg. LogLevel warn CustomLog ${APACHE_LOG_DIR}/ssl_access.log combined Alias /doc/ "/usr/share/doc/" <Directory "/usr/share/doc/"> Options Indexes MultiViews FollowSymLinks AllowOverride None Order deny,allow Deny from all Allow from 127.0.0.0/255.0.0.0 ::1/128 </Directory> # 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.2-common/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/apache2/ssl/apache.crt SSLCertificateKeyFile /etc/apache2/ssl/apache.key 

我的ports.conf:

 NameVirtualHost *:80 NameVirtualHost *:443 Listen 80 <IfModule mod_ssl.c> # If you add NameVirtualHost *:443 here, you will also have to change # the VirtualHost statement in /etc/apache2/sites-available/default-ssl # to <VirtualHost *:443> # Server Name Indication for SSL named virtual hosts is currently not # supported by MSIE on Windows XP. ErrorLog /var/log/apache2/ssl_access.log LogLevel debug Listen 443 </IfModule> <IfModule mod_gnutls.c> Listen 443 </IfModule> 

我还编辑了/ etc / hosts和/ etc / hostname并添加了ip地址

我查看了/var/log/apache2/error.log,有两行可能表示问题:

 RSA server certificate is a CA certificate RSA server certificate CommonName (CN) `54.82.28.171' does NOT match server name!? 

我真的很难find问题所在。 我确定这是愚蠢的,但我不明白是什么!

编辑:

我只是试图openssl s_client -connect 54.82.28.171:443我得到了:

 connect: Connection timed out connect:errno=110 

我认为这意味着连接被拒绝,意味着端口443不能打开? 当我说不加载我的意思是浏览器说“网页无法访问”。 当我试图访问相同的页面没有https我的index.html页面正在加载

否则,输出apache2ctl -S:

 /usr/sbin/apache2ctl: 87: ulimit: error setting limit (Operation not permitted) VirtualHost configuration: wildcard NameVirtualHosts and _default_ servers: *:443 is a NameVirtualHost default server 54.82.28.171 (/etc/apache2/sites-enabled/default-ssl:3) port 443 namevhost 54.82.28.171 (/etc/apache2/sites-enabled/default-ssl:3) *:80 is a NameVirtualHost default server dash.amatiscontrols.com (/etc/apache2/sites-enabled/000-default:1) port 80 namevhost dash.amatiscontrols.com (/etc/apache2/sites-enabled/000-default:1) port 80 namevhost amatisdash.com (/etc/apache2/sites-enabled/amatisdash.com:1) Syntax OK 

编辑:有服务器上的防火墙…没有443打开,所以它应该解释一切。 除了我自己可以打开这个港口外,还要等一下。 无论如何谢谢你!

谢谢

可能有助于分解SSL尝试时发生的实际情况。 时间打破openssl!

看看openssl的以下手册页: https : //www.openssl.org/docs/apps/s_client.html

仔细看注释部分提供的参考(只需向下滚动)。 正如它声明,您可以尝试以下操作:

openssl s_client -connect servername:443

这可能会为您提供有关失败的更多信息。

至于错误日志条目 – 第一行是好奇的…我想知道如果可能的证书使用是不是很正确…第二行是更常见的,虽然通常是由于连接基于IP时,证书被发布到FQDN …我会开始与openssl连接testing,看看你是否可以收集更多的信息。

最后但并非最不重要的,虽然…你说的网页不加载,你得到一个错误,或者它只是显示一个空白页面? 只要确保你实际上在页面上呈现的东西:)

ServerName 54.82.28.171:443不是一个有效的服务器名称,因为它是一个IP地址和端口,而不是一个完全合格的域名,它应该像ServerName www.example.com

其次,您的ServerName应与SSL证书中的公用名称相同,无论您使用IP地址54.82.28.171:443 != 54.82.28.171

第三个错误消息似乎是您的公共证书根本不是自签名证书,而是CA证书。 这可能是因为通用名称不是FQDN而是IP地址,我不确定。
您可以将您当前的证书/etc/apache2/ssl/apache.crt从PEM编码转换为更清晰的文件,内容如下:

 openssl x509 -in apache.crt -noout -text 

包含如下内容的结果:

  X509v3 Basic Constraints: CA:TRUE 

是Aapche认为该证书是CA证书的一个可能的原因,这与IIRC自签名证书不一定是错误的。