openssl 测试后端口 443 切换为过滤

openssl 测试后端口 443 切换为过滤

当我在调查的时候此问题与 SSL 有关(在 StackOverflow 中以 OT 形式发布),我发现了一个奇怪的行为。

前提

前提是我试图理解为什么我的网络服务器(托管在运行基于网络的应用程序的 CentOs 6 VPS 上)在访问时没有回复,而https://my.site.com同一网站在http://my.site.com.在VPS上运行的Apache 2.2应该已正确配置为侦听端口 443。

奇怪的行为

让我们看看以下输出序列。我从 shell 运行以下三个命令来检查端口 443偏僻的服务器,假设 IP 地址为 XXX.XXX.XXX.XXX 的 my.site.com。我屏蔽了一些具体信息

# nmap -p443 XXX.XXX.XXX.XXX

Starting Nmap 6.47 ( http://nmap.org ) at 2017-01-07 23:32 CET
Nmap scan report for [some-host] (XXX.XXX.XXX.XXX)
Host is up (0.0021s latency).
PORT    STATE SERVICE
443/tcp open  https

Nmap done: 1 IP address (1 host up) scanned in 1.16 seconds

# openssl s_client -connect XXX.XXX.XXX.XXX:443
CONNECTED(00000003)
3069269200:error:140790E5:SSL routines:SSL23_WRITE:ssl handshake failure:s23_lib.c:177:
---
no peer certificate available
---
No client certificate CA names sent
---
SSL handshake has read 0 bytes and written 289 bytes
---
New, (NONE), Cipher is (NONE)
Secure Renegotiation IS NOT supported
Compression: NONE
Expansion: NONE
SSL-Session:
    Protocol  : TLSv1.2
    Cipher    : 0000
    Session-ID: 
    Session-ID-ctx: 
    Master-Key: 
    Key-Arg   : None
    PSK identity: None
    PSK identity hint: None
    SRP username: None
    Start Time: 1483830497
    Timeout   : 300 (sec)
    Verify return code: 0 (ok)
---

# nmap -p443 XXX.XXX.XXX.XXX

Starting Nmap 6.47 ( http://nmap.org ) at 2017-01-08 00:08 CET
Nmap scan report for [some-host] (XXX.XXX.XXX.XXX)
Host is up (0.064s latency).
PORT    STATE    SERVICE
443/tcp filtered https

Nmap done: 1 IP address (1 host up) scanned in 1.25 seconds

看来443端口变成了过滤的在我运行 OpenSSL 后立即使用 nmap。这怎么可能?这种行为的原因可能是什么?

编辑

在远程服务器上本地运行的命令openssl给出以下输出,因此看来证书配置正确(如果我错了,请告诉我):

# openssl s_client -connect localhost:443
CONNECTED(00000003)
depth=2 O = [some CA], CN = [some CA] Root CA X3
verify return:1
depth=1 C = US, O = [some CA], CN = [some CA] X3
verify return:1
depth=0 CN = my.site.com
verify return:1
---
Certificate chain
 0 s:/CN=my.site.com
   i:/C=US/O=[some CA]/CN=[some CA] X3
 1 s:/C=US/O=[some CA]/CN=[some CA] X3
   i:/O=[some CA]/CN=[some CA] Root CA X3
---
Server certificate
-----BEGIN CERTIFICATE-----
[some data]
-----END CERTIFICATE-----
subject=/CN=my.site.com
issuer=/C=US/O=[some CA]/CN=[some CA] X3
---
No client certificate CA names sent
Server Temp Key: ECDH, prime256v1, 256 bits
---
SSL handshake has read 3672 bytes and written 373 bytes
---
New, TLSv1/SSLv3, Cipher is ECDHE-RSA-AES256-GCM-SHA384
Server public key is 4096 bit
Secure Renegotiation IS supported
Compression: NONE
Expansion: NONE
SSL-Session:
    Protocol  : TLSv1.2
    Cipher    : ECDHE-RSA-AES256-GCM-SHA384
    Session-ID: F2F71647F95F40CA29C5AA8628D76B466C8B89CFF5A1992B88DDC121FB376345
    Session-ID-ctx: 
    Master-Key: [some data]
    Key-Arg   : None
    Krb5 Principal: None
    PSK identity: None
    PSK identity hint: None
    TLS session ticket lifetime hint: 300 (seconds)
    TLS session ticket:
    [some data]

    Start Time: 1483840507
    Timeout   : 300 (sec)
    Verify return code: 0 (ok)
---

相关内容