我有一个想成为VPN服务器的AWS实例。它将Windows 7客户端连接到Amazon云中的专用网络。
- 我已经安装了Ubuntu 12.04和
strongswan-ikev2
软件包。 ipsec version
报告Linux strongSwan U4.5.2/K3.2.0-52-virtual
- 请注意,客户端和服务器都在NAT后面(客户端是因为它在本地办公网络上,而服务器是因为它在亚马逊的云中)。我在Amazon仪表板和客户端防火墙上均已解除阻止UDP端口500和4500。
这是/etc/ipsec.conf:
config setup plutostart=no conn %default keyexchange=ikev2 ike=aes256-sha1-modp1024! esp=aes256-sha1! dpdaction=clear dpddelay=300s rekey=no conn win7vpn left=%any leftsubnet=<amazon VPC CIDR block> leftauth=pubkey leftcert=openssl-cert.pem leftid=<vpn server public dns name> right=%any rightsourceip=<amazon private IP address, which elastic ip is forwarded to> rightauth=eap-mschapv2 rightsendcert=never eap_identity=%any auto=add
这是/etc/ipsec.secrets:
: RSA openssl-key.rsa TESTDOMAIN\testuser : EAP "testpassword"
我已将对服务器的主机证书进行签名的CA证书添加到本地计算机(而非用户)证书存储中,以便Windows可以对服务器进行身份验证。
然后,我尝试按照此处规定使用Windows 7客户端连接到服务器,但有一个例外-我使用的是DNS名称而不是IP地址。我在ipsec.secrets文件中输入用户名,域和密码,然后尝试连接。
这样做时,我会得到如下所示的strongSwan日志。为了审查和清晰起见,我对此稍加思索。CLIENTPUB / CLIENTPRIV是客户端的公用和专用IP地址,而AMAZONPRIV是服务器的专用IP地址(这是服务器的公用IP(Amazon称为“弹性IP”)转发到的地址)。
Sep 4 00:16:17 localhost charon: 14[IKE] CLIENTPUB is initiating an IKE_SA
Sep 4 00:16:17 localhost charon: 14[NET] received packet: from CLIENTPUB[500] to AMAZONPRIV[500]
Sep 4 00:16:17 localhost charon: 14[ENC] parsed IKE_SA_INIT request 0 [ SA KE No N(NATD_S_IP) N(NATD_D_IP) ]
Sep 4 00:16:17 localhost charon: 14[IKE] CLIENTPUB is initiating an IKE_SA
Sep 4 00:16:17 localhost charon: 14[IKE] local host is behind NAT, sending keep alives
Sep 4 00:16:17 localhost charon: 14[IKE] remote host is behind NAT
Sep 4 00:16:17 localhost charon: 14[ENC] generating IKE_SA_INIT response 0 [ SA KE No N(NATD_S_IP) N(NATD_D_IP) N(MULT_AUTH) ]
Sep 4 00:16:17 localhost charon: 14[NET] sending packet: from AMAZONPRIV[500] to CLIENTPUB[500]
Sep 4 00:16:17 localhost charon: 15[NET] received packet: from CLIENTPUB[4500] to AMAZONPRIV[4500]
Sep 4 00:16:17 localhost charon: 15[ENC] unknown attribute type INTERNAL_IP4_SERVER
Sep 4 00:16:17 localhost charon: 15[ENC] parsed IKE_AUTH request 1 [ IDi CERTREQ N(MOBIKE_SUP) CP(ADDR DNS NBNS SRV) SA TSi TSr ]
Sep 4 00:16:17 localhost charon: 15[IKE] received cert request for "C=US, ST=TX, O=Test CA, CN=Test CA"
Sep 4 00:16:17 localhost charon: 15[IKE] received 316 cert requests for an unknown ca
Sep 4 00:16:17 localhost charon: 15[CFG] looking for peer configs matching AMAZONPRIV[%any]...CLIENTPUB[CLIENTPRIV]
Sep 4 00:16:17 localhost charon: 15[CFG] selected peer config 'dlpvpn'
Sep 4 00:16:17 localhost charon: 15[IKE] initiating EAP-Identity request
Sep 4 00:16:17 localhost charon: 15[IKE] peer supports MOBIKE
Sep 4 00:16:17 localhost charon: 15[IKE] authentication of 'C=US, ST=TX, O=DLP Test CA, CN=vpn.example.com' (myself) with RSA signature successful
Sep 4 00:16:17 localhost charon: 15[IKE] sending end entity cert "C=US, ST=TX, O=DLP Test CA, CN=vpn.example.com"
Sep 4 00:16:17 localhost charon: 15[ENC] generating IKE_AUTH response 1 [ IDr CERT AUTH EAP/REQ/ID ]
Sep 4 00:16:17 localhost charon: 15[NET] sending packet: from AMAZONPRIV[4500] to CLIENTPUB[4500]
此时,Windows立即弹出错误消息:
Verifying user name and password...
Error 13801: IKE authentication credentials are unacceptable
几秒钟后,charon再次尝试,然后关闭连接。
Sep 4 00:16:37 localhost charon: 16[IKE] sending keep alive
Sep 4 00:16:37 localhost charon: 16[NET] sending packet: from AMAZONPRIV[4500] to CLIENTPUB[4500]
Sep 4 00:16:47 localhost charon: 03[JOB] deleting half open IKE_SA after timeout
就是这样。
据我所知,我正在遵循StrongSwan Wiki上的所有说明。
我在这里做错了什么?
编辑:这绝对是证书的问题。我通过编辑注册表并按照MSKB926182中的说明重新启动来禁用扩展的验证检查(如果您需要链接,请大声笑),现在我可以毫无错误地连接到我的VPN服务器。我将弄清楚如何生成满足要求的证书并添加答案。感谢@ecdsa提供了指向StrongSwan Wiki上的cert页面的指针,它使我获得了正确的方向。