大网数据广告活动
服务器运维问答

Apache 2.4 drop connection on default SSL host

· 52CE 我爱测

I am running Apache 2.4 on Debian serving some SSL websites. My domain name und certificates contain my real name, so I don't want any random user typing in my IP address to get the certificate und my name. My approach would be t…

问题原文

原帖链接 · soelderer · CC BY-SA 4.0

I am running Apache 2.4 on Debian serving some SSL websites. My domain name und certificates contain my real name, so I don't want any random user typing in my IP address to get the certificate und my name.

My approach would be to create a default virtual host on port 443 to drop all connections using modsecurity, so you only get the certificate if you know the domain name. With SNI it should be possible - Apache determines the right virtual host before the TLS handshake, right?

It does not seem to work as expected, however. If I enable the default host, every TLS connection seems to get dropped and I get a SSL_ERROR_RX_RECORD_TOO_LONG error in the browser.

This is my configuration:

<VirtualHost *:443>
    ServerName defaultserverssl
    DocumentRoot /var/www/html
    SecRuleEngine On
    SecAction id:1,phase:1,nolog,drop
</VirtualHost>

<IfModule mod_ssl.c>
<VirtualHost *:443>
    ServerName www1.example.com
    DocumentRoot /my/document/root

    SSLCertificateFile /path/to/myfullchain.pem
    SSLCertificateKeyFile /path/to/myprivkey.pem
    Include /etc/letsencrypt/options-ssl-apache.conf
</VirtualHost>
</IfModule>

<IfModule mod_ssl.c>
<VirtualHost *:443>
    ServerName www2.example.com
    DocumentRoot /my/document/root

    SSLCertificateFile /path/to/myfullchain.pem
    SSLCertificateKeyFile /path/to/myprivkey.pem
    Include /etc/letsencrypt/options-ssl-apache.conf
</VirtualHost>
</IfModule>

I already tried the SSLStrictSNIVHostCheck option to force SNI, both on server level and in the individual vhosts, with no different result.

It looks like SNI is not working, or am I wrong about the way SNI works and my approach is not possible?

已采纳解答

原帖链接 · soelderer · CC BY-SA 4.0

I have found a workaround for my problem.

As far as I understand, with SNI the client sends the requested server name within an extended TLS client hello - so there is no way to avoid an initial TLS handshake (or at least I didn't find a way to drop the connection just after receiving the client hello).

As a workaround, I created a self-signed certificate (containing no personal information) that I use with the default host. After the handshake dropping the connection seems to work.

<VirtualHost *:443>
    ServerName defaultserverssl
    DocumentRoot /var/www/html

    SSLEngine On
    SSLCertificateFile /path/to/self-signed/default.crt
    SSLCertificateKeyFile /path/to/self-signed/default.key

    SecRuleEngine On
    SecAction id:1,phase:1,nolog,drop
</VirtualHost>

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2018-06-20)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。