diff --git a/README-zh.md b/README-zh.md index 3fb7c85..716472f 100644 --- a/README-zh.md +++ b/README-zh.md @@ -129,7 +129,7 @@ VPN_PASSWORD='你的VPN密码' sh vpnsetup.sh **配置 IPsec/XAuth ("Cisco IPsec") VPN 客户端** -**如何配置 IKEv2 VPN: Windows, Android 和 iOS** +**如何配置 IKEv2 VPN: Windows, macOS, Android 和 iOS** 如果在连接过程中遇到错误,请参见 故障排除。 diff --git a/README.md b/README.md index a9d9325..57fcb61 100644 --- a/README.md +++ b/README.md @@ -129,7 +129,7 @@ Get your computer or device to use the VPN. Please refer to: **Configure IPsec/XAuth ("Cisco IPsec") VPN Clients** -**How-To: IKEv2 VPN for Windows, Android and iOS** +**How-To: IKEv2 VPN for Windows, macOS, Android and iOS** If you get an error when trying to connect, see Troubleshooting. diff --git a/docs/clients-zh.md b/docs/clients-zh.md index 4c0bc6d..1c25a60 100644 --- a/docs/clients-zh.md +++ b/docs/clients-zh.md @@ -83,7 +83,7 @@ ## OS X -**注:** 你也可以使用更高效的 [IPsec/XAuth 模式](clients-xauth-zh.md) 连接。 +**注:** 你也可以使用更高效的 [IPsec/XAuth 模式](clients-xauth-zh.md) 连接,或者配置 [IKEv2](ikev2-howto-zh.md)。 1. 打开系统偏好设置并转到网络部分。 1. 在窗口左下角单击 **+** 按钮。 diff --git a/docs/clients.md b/docs/clients.md index f99f601..d62f84d 100644 --- a/docs/clients.md +++ b/docs/clients.md @@ -83,7 +83,7 @@ If you get an error when trying to connect, see Troub ## OS X -**Note:** You may also connect using the faster [IPsec/XAuth mode](clients-xauth.md). +**Note:** You may also connect using the faster [IPsec/XAuth mode](clients-xauth.md), or set up [IKEv2](ikev2-howto.md). 1. Open System Preferences and go to the Network section. 1. Click the **+** button in the lower-left corner of the window. diff --git a/docs/ikev2-howto-zh.md b/docs/ikev2-howto-zh.md index 69989db..dd79ba3 100644 --- a/docs/ikev2-howto-zh.md +++ b/docs/ikev2-howto-zh.md @@ -1,4 +1,4 @@ -# 如何配置 IKEv2 VPN: Windows, Android 和 iOS +# 如何配置 IKEv2 VPN: Windows, macOS, Android 和 iOS *其他语言版本: [English](ikev2-howto.md), [简体中文](ikev2-howto-zh.md).* @@ -13,6 +13,7 @@ Windows 7 和更新版本支持 IKEv2 协议标准,通过 Microsoft 的 Agile Libreswan 支持通过使用 RSA 签名算法的 X.509 Machine Certificates 来对 IKEv2 客户端进行身份验证。该方法无需 IPsec PSK, 用户名或密码。它可以用于以下系统: - Windows 7, 8.x 和 10 +- OS X (macOS) - Android 4.x 和更新版本(使用 strongSwan VPN 客户端) - iOS (iPhone/iPad) @@ -132,7 +133,7 @@ Libreswan 支持通过使用 RSA 签名算法的 X.509 Machine Certificates 来 Generating key. This may take a few moments... ``` -1. 生成客户端证书,导出 CA 证书以及 `.p12` 文件,该文件包含客户端证书,私钥以及 CA 证书: +1. 生成客户端证书,然后导出 `.p12` 文件,该文件包含客户端证书,私钥以及 CA 证书: ```bash $ certutil -z <(head -c 1024 /dev/urandom) \ @@ -148,12 +149,6 @@ Libreswan 支持通过使用 RSA 签名算法的 X.509 Machine Certificates 来 Generating key. This may take a few moments... ``` - ```bash - $ certutil -L -d sql:/etc/ipsec.d -n "IKEv2 VPN CA" -a -o vpnca.cer - ``` - - **注:** 这个 `vpnca.cer` 文件仅需要在 iOS 客户端上使用。 - ```bash $ pk12util -o vpnclient.p12 -n "vpnclient" -d sql:/etc/ipsec.d ``` @@ -164,10 +159,16 @@ Libreswan 支持通过使用 RSA 签名算法的 X.509 Machine Certificates 来 pk12util: PKCS12 EXPORT SUCCESSFUL ``` - 指定一个安全的密码以保护导出的 `.p12` 文件。你可以重复本步骤来为更多的客户端生成证书。将所有的 `vpnclient` 换成 `vpnclient2`,等等。 + 指定一个安全的密码以保护导出的 `.p12` 文件(在导入到 iOS 设备时,该密码不能为空)。你可以重复本步骤来为更多的客户端生成证书。将所有的 `vpnclient` 换成 `vpnclient2`,等等。 **注:** 如需同时连接多个客户端,则必须为每个客户端生成唯一的证书。 +1. (适用于 macOS 和 iOS 客户端) 导出 CA 证书到 `vpnca.cer`: + + ```bash + $ certutil -L -d sql:/etc/ipsec.d -n "IKEv2 VPN CA" -a -o vpnca.cer + ``` + 1. 证书数据库现在应该包含以下内容: ```bash @@ -191,11 +192,11 @@ Libreswan 支持通过使用 RSA 签名算法的 X.509 Machine Certificates 来 $ service ipsec restart ``` -1. 将文件 `vpnclient.p12` 安全地传送到 VPN 客户端设备。然后按照你的操作系统对应的步骤操作。**注:** 如果你在上面的第一步指定了服务器的域名,则需要在 **Server** 和 **Remote ID** 字段中输入域名而不是 IP 地址。 +1. 按照你的操作系统对应的步骤操作。请注意,如果你在上面的第一步指定了服务器的域名,则需要在 **服务器地址** 和 **远程 ID** 字段中输入该域名而不是 IP 地址。 #### Windows 7, 8.x 和 10 - 1. 将 `.p12` 文件导入到 "计算机账户" 证书存储。在导入证书后,你必须确保将客户端证书放在 "个人 -> 证书" 目录中,并且将 CA 证书放在 "受信任的根证书颁发机构 -> 证书" 目录中。 + 1. 将文件 `vpnclient.p12` 安全地传送到你的计算机,然后导入到 "计算机账户" 证书存储。在导入证书后,你必须确保将客户端证书放在 "个人 -> 证书" 目录中,并且将 CA 证书放在 "受信任的根证书颁发机构 -> 证书" 目录中。 详细的操作步骤: https://wiki.strongswan.org/projects/strongswan/wiki/Win7Certs @@ -208,9 +209,30 @@ Libreswan 支持通过使用 RSA 签名算法的 X.509 Machine Certificates 来 1. (可选步骤) 如需启用更强的加密算法,你可以添加注册表键 `NegotiateDH2048_AES256` 并重启。更多信息请看这里。 + #### OS X (macOS) + + 首先,将文件 `vpnca.cer` 和 `vpnclient.p12` 安全地传送到你的 Mac,然后双击它们并逐个导入到 **钥匙串访问** 中的 **登录** 钥匙串。下一步,双击刚才导入的 `IKEv2 VPN CA` 证书,展开 **信任** 并从 **IP 安全 (IPsec)** 下拉菜单中选择 **始终信任**。在完成之后,检查并确保 `vpnclient` 和 `IKEv2 VPN CA` 都显示在 **登录** 钥匙串 的 **证书** 类别中。 + + 1. 打开系统偏好设置并转到网络部分。 + 1. 在窗口左下角单击 **+** 按钮。 + 1. 从 **接口** 下拉菜单选择 **VPN**。 + 1. 从 **VPN 类型** 下拉菜单选择 **IKEv2**。 + 1. 在 **服务名称** 字段中输入任意内容。 + 1. 单击 **创建**。 + 1. 在 **服务器地址** 字段中输入 `你的 VPN 服务器 IP` (或者域名)。 + 1. 在 **远程 ID** 字段中输入 `你的 VPN 服务器 IP` (或者域名)。 + 1. 保持 **本地 ID** 字段空白。 + 1. 单击 **鉴定设置...** 按钮。 + 1. 从 **鉴定设置** 下拉菜单中选择 **无**。 + 1. 选择 **证书** 单选按钮,然后选择 **vpnclient** 证书。 + 1. 单击 **好**。 + 1. 选中 **在菜单栏中显示 VPN 状态** 复选框。 + 1. 单击 **应用** 保存VPN连接信息。 + 1. 单击 **连接**。 + #### Android 4.x 和更新版本 - 1. 从 **Google Play** 安装 strongSwan VPN 客户端。 + 1. 将文件 `vpnclient.p12` 安全地传送到你的设备,然后从 **Google Play** 安装 strongSwan VPN 客户端。 1. 打开 VPN 客户端,然后单击 **Add VPN Profile**。 1. 在 **Server** 字段中输入 `你的 VPN 服务器 IP` (或者域名)。 1. 在 **VPN Type** 下拉菜单选择 **IKEv2 Certificate**。 @@ -220,7 +242,7 @@ Libreswan 支持通过使用 RSA 签名算法的 X.509 Machine Certificates 来 #### iOS (iPhone/iPad) - 首先,将你在上面的步骤 4 中导出的两个文件 `vpnca.cer` and `vpnclient.p12` 以电子邮件附件的形式发送给你自己,然后在 iOS 邮件应用中点击它们并逐个导入为 iOS 配置描述文件。或者,你也可以将文件放在一个你的安全的托管网站上,然后在 Mobile Safari 中下载并导入。在完成之后,检查并确保 `vpnclient` 和 `IKEv2 VPN CA` 都显示在设置 -> 通用 -> 描述文件中。 + 首先,将文件 `vpnca.cer` 和 `vpnclient.p12` 以电子邮件附件的形式发送给你自己,然后在 iOS 邮件应用中点击它们并逐个导入为 iOS 配置描述文件。或者,你也可以将文件放在一个你的安全的托管网站上,然后在 Mobile Safari 中下载并导入它们。在完成之后,检查并确保 `vpnclient` 和 `IKEv2 VPN CA` 都显示在设置 -> 通用 -> 描述文件中。 1. 进入设置 -> 通用 -> VPN。 1. 单击 **添加VPN配置...**。 @@ -241,7 +263,6 @@ Libreswan 支持通过使用 RSA 签名算法的 X.509 Machine Certificates 来 1. Windows 自带的 VPN 客户端可能不支持 IKEv2 fragmentation。在有些网络上,这可能会导致连接错误或其它连接问题。你可以尝试换用 IPsec/L2TPIPsec/XAuth 模式连接。 1. 如果你使用 strongSwan Android VPN 客户端,则必须将服务器上的 Libreswan 升级到版本 3.26 或以上。 -1. 在导入到 iOS 设备时,`.p12` 文件的密码不能为空。要解决这个问题,按照步骤 4 中的命令重新导出 `.p12` 文件并指定一个安全的密码。 ## 参考链接 diff --git a/docs/ikev2-howto.md b/docs/ikev2-howto.md index 4dbe23d..787ce74 100644 --- a/docs/ikev2-howto.md +++ b/docs/ikev2-howto.md @@ -1,4 +1,4 @@ -# How-To: IKEv2 VPN for Windows, Android and iOS +# How-To: IKEv2 VPN for Windows, macOS, Android and iOS *Read this in other languages: [English](ikev2-howto.md), [简体中文](ikev2-howto-zh.md).* @@ -13,6 +13,7 @@ Windows 7 and newer releases support the IKEv2 standard through Microsoft's Agil Libreswan can authenticate IKEv2 clients on the basis of X.509 Machine Certificates using RSA signatures. This method does not require an IPsec PSK, username or password. It can be used with: - Windows 7, 8.x and 10 +- OS X (macOS) - Android 4.x and newer (using the strongSwan VPN client) - iOS (iPhone/iPad) @@ -132,7 +133,7 @@ Before continuing, make sure you have successfully Certificates", and the CA cert is placed in "Trusted Root Certification Authorities -> Certificates". + 1. Securely transfer `vpnclient.p12` to your computer, then import it into the "Computer account" certificate store. Make sure that the client cert is placed in "Personal -> Certificates", and the CA cert is placed in "Trusted Root Certification Authorities -> Certificates". Detailed instructions: https://wiki.strongswan.org/projects/strongswan/wiki/Win7Certs @@ -208,9 +209,30 @@ Before continuing, make sure you have successfully here. + #### OS X (macOS) + + First, securely transfer both `vpnca.cer` and `vpnclient.p12` to your Mac, then double-click to import them one by one into the **login** keychain in **Keychain Access**. Next, double-click on the imported `IKEv2 VPN CA` certificate, expand **Trust** and select **Always Trust** from the **IP Security (IPsec)** drop-down menu. When finished, check to make sure both `vpnclient` and `IKEv2 VPN CA` are listed under the **Certificates** category of **login** keychain. + + 1. Open System Preferences and go to the Network section. + 1. Click the **+** button in the lower-left corner of the window. + 1. Select **VPN** from the **Interface** drop-down menu. + 1. Select **IKEv2** from the **VPN Type** drop-down menu. + 1. Enter anything you like for the **Service Name**. + 1. Click **Create**. + 1. Enter `Your VPN Server IP` (or DNS name) for the **Server Address**. + 1. Enter `Your VPN Server IP` (or DNS name) for the **Remote ID**. + 1. Leave the **Local ID** field blank. + 1. Click the **Authentication Settings...** button. + 1. Select **None** from the **Authentication Settings** drop-down menu. + 1. Select the **Certificate** radio button, then select the **vpnclient** certificate. + 1. Click **OK**. + 1. Check the **Show VPN status in menu bar** checkbox. + 1. Click **Apply** to save the VPN connection information. + 1. Click **Connect**. + #### Android 4.x and newer - 1. Install strongSwan VPN Client from **Google Play**. + 1. Securely transfer `vpnclient.p12` to your device. Then install strongSwan VPN Client from **Google Play**. 1. Launch the VPN client and tap **Add VPN Profile**. 1. Enter `Your VPN Server IP` (or DNS name) in the **Server** field. 1. Select **IKEv2 Certificate** from the **VPN Type** drop-down menu. @@ -220,7 +242,7 @@ Before continuing, make sure you have successfully IPsec/L2TP or IPsec/XAuth mode. 1. If using the strongSwan Android VPN client, you must upgrade Libreswan on your server to version 3.26 or above. -1. The `.p12` file cannot have an empty password when importing into an iOS device. To resolve this issue, follow instructions in step 4 to re-export the file with a secure password. ## References