访问 Cisco IOS 上的 HTTP 安全服务器

网络工程 思科 ios-xe
2021-07-21 20:14:29

我有一个运行 IOS XE 版本 16.09.04 的 Cisco ISR4331/K9,我配置了主机名、域名并生成了 2048 位 RSA 密钥,我还验证了时钟设置是否正确。

配置后,ip http secure-server我尝试从运行 Firefox 83.0 的 PC 访问路由器

当 HTTP 访问正常时,HTTPS 会在 Firefox 中遇到错误“SSL_ERROR_NO_CYPHER_OVERLAP”。但是 ash ip http server secure status返回:

HTTP secure server status: Enabled
HTTP secure server port: 443
HTTP secure server ciphersuite:  3des-ede-cbc-sha aes-128-cbc-sha
        aes-256-cbc-sha dhe-aes-128-cbc-sha ecdhe-rsa-3des-ede-cbc-sha
        rsa-aes-cbc-sha2 rsa-aes-gcm-sha2 dhe-aes-cbc-sha2 dhe-aes-gcm-sha2
        ecdhe-rsa-aes-cbc-sha2 ecdhe-rsa-aes-gcm-sha2 ecdhe-ecdsa-aes-gcm-sha2
HTTP secure server TLS version:  TLSv1.2 TLSv1.1
HTTP secure server client authentication: Disabled
HTTP secure server PIV authentication: Disabled
HTTP secure server trustpoint: 
HTTP secure server peer validation trustpoint: 
HTTP secure server ECDHE curve: secp256r1
HTTP secure server active session modules: ALL

这似乎是 Firefox 完全可以接受的密码套件列表。

在 Wireshak 中查看时,路由器似乎在来自客户端的 TLSv1.2 Hello 消息之后立即向浏览器返回 TLSv1.2 致命握手错误消息。

debug ip http all在这次握手期间,我在使用的路由器上根本没有收到任何消息

知道我在这里缺少什么吗?

请注意,这是我用于复制/调试此问题的实验室路由器,因此缺少大多数配置。路由器配置:

routertest#sh run
Building configuration...


Current configuration : 1787 bytes
!
! Last configuration change at 18:22:01 UTC Fri Jan 29 2021
!
version 16.9
service timestamps debug datetime msec
service timestamps log datetime msec
platform qfp utilization monitor load 80
no platform punt-keepalive disable-kernel-core
!
hostname routertest
!
boot-start-marker
boot-end-marker
!
!
vrf definition Mgmt-intf
 !
 address-family ipv4
 exit-address-family
 !
 address-family ipv6
 exit-address-family
!
!
no aaa new-model
!
no ip domain lookup
ip domain name test.com
!
!
!
login on-success log
!
!
!
!
!
!
!
subscriber templating
! 
! 
! 
! 
!         
multilink bundle-name authenticated
!
!
!
crypto pki trustpoint TP-self-signed-886488406
 enrollment selfsigned
 subject-name cn=IOS-Self-Signed-Certificate-886488406
 revocation-check none
 rsakeypair TP-self-signed-886488406
!
!
crypto pki certificate chain TP-self-signed-886488406
!
license udi pid ISR4331/K9 sn FDO19370HXL
license boot level securityk9
no license smart enable
diagnostic bootup level minimal
!
spanning-tree extend system-id
!
!
!
!         
redundancy
 mode none
!
!
!
!
!
!
! 
!
!
!
!
!
!
!
!
!
!
! 
! 
!
!         
interface GigabitEthernet0/0/0
 no ip address
 shutdown
 negotiation auto
!
interface GigabitEthernet0/0/1
 ip address 10.30.0.1 255.255.255.0
 negotiation auto
!
interface GigabitEthernet0/0/2
 no ip address
 shutdown
 negotiation auto
!
interface Serial0/1/0
 no ip address
!
interface Serial0/1/1
 no ip address
!
interface GigabitEthernet0
 vrf forwarding Mgmt-intf
 no ip address
 shutdown
 negotiation auto
!
ip forward-protocol nd
ip http server
ip http authentication local
ip http secure-server
ip tftp source-interface GigabitEthernet0
!
!
!
!
!
!
control-plane
!
!
line con 0
 logging synchronous
 transport input none
 stopbits 1
line aux 0
 stopbits 1
line vty 0 4
 login
!
!
!
!
!
!
end
1个回答

经过广泛的测试,我能够弄清楚这一点。据我所知,思科并未正式记录,例如他们的HTTP 服务配置指南仍将其中一些步骤列为可选步骤,但似乎在较新的硬件或软件上,可选步骤之一已成为强制性步骤。

特别是,当启用 HTTPS 时,旧的 Cisco 设备会自动将 HTTPS 服务器链接到自签名信任点。尽管启用 HTTPS 仍会为您生成密钥、证书和信任点,但 HTTPS 服务器不再自动使用该信任点进行连接,因此您必须通过ip http secure-trustpoint命令手动告诉 HTTPS 服务器使用正确的信任点

我怀疑这是一个无意中在某处引入的错误,因为它仍然自动为您完成其他所有工作,包括创建信任点,HTTPS 服务器只是不会自动选择它创建的信任点作为要使用的信任点。

事实上,IOS 16.9 命令参考指南指出“命令默认值:HTTPS 服务器使用您使用主命令时配置的信任点。如果未配置信任点,HTTPS 服务器使用自签名证书。” 和“如果不使用此命令,服务器将尝试使用与主信任点关联的证书。” 这些表明当自签名证书是路由器上的唯一证书时(因为它在启用 HTTPS 服务器后开箱即用)ip http secure-trustpoint不应需要命令。

因此,如果您ip http secure-server在路由器上运行命令后仔细查看终端日志,您将看到如下输出:

r2(config)#ip http secure-server
CRYPTO_PKI: setting trustpoint policy TP-self-signed-3189949043 to use keypair TP-self-signed-3189949043% Generating 2048 bit RSA keys, keys will be non-exportable...
[OK] (elapsed time was 5 seconds)
*Jan 30 09:50:16.152: %CRYPTO_ENGINE-5-KEY_ADDITION: A key named TP-self-signed-3189949043 has been generated or imported by crypto-engine
*Jan 30 09:50:16.243: %PKI-4-NOCONFIGAUTOSAVE: Configuration was modified.  Issue "write memory" to save new IOS PKI configuration

这将为您提供创建的信任点的名称,在我的例子中是“TP-self-signed-3189949043”。

请注意,如果您在启用 HTTPS 服务器期间错过了此消息,您可以事后在路由器的配置中找到信任点。

然后新需要的步骤是通过命令告诉 HTTPS 服务器使用该信任点ip http secure-trustpoint TP-self-signed-3189949043(用您的信任点名称替换信任点名称)。

完成此操作后,浏览器将能够使用信任自签名证书的正常过程连接到 HTTPS 服务器。

请注意,这在生产环境中不太可能发生,因为如果您使用 CA 签名的证书(而不是自签名证书),则必须设置信任点。