更新为多种 IKE 和 IPsec 算法

VPN for VPC 支持为 IKE 和 IPsec 策略配置多种算法。 使用多种算法可以提高兼容性、灵活性和安全性。

请按照以下说明,将已弃用的单个算法属性迁移为多个算法属性。

准备工作

在更新 VPN 策略之前,请仔细阅读以下信息。

废弃的奇异算法属性

自 2026 年 5 月 29 日起,VPN IKE 和 IPsec 单一算法属性已被弃用。 已配置了特定属性的现有 VPN 连接将继续正常运行,无需进行任何更改。 不过,建议尽快更新为基于数组的算法属性。

IKE 策略的奇异算法和基于数组的算法特性
IKE 单一属性(已弃用) IKE 多属性(推荐)
authentication_algorithm authentication_algorithms
encryption_algorithm encryption_algorithms
dh_group dh_groups
IPsec 策略的奇异算法和基于数组的算法特性
IPsec 单一属性(已弃用) IPsec 多属性(推荐)
authentication_algorithm authentication_algorithms
encryption_algorithm encryption_algorithms
pfs pfs_groups

当您的 VPN 环境需要与支持不同加密算法的对等节点兼容,或者您希望在保持向后兼容性的同时优先采用更强的加密方式时,请使用多种算法。

重要注意事项

  • 使用自定义 IKE 或 IPsec 策略且包含已弃用的单一算法属性的 VPN 连接,可能会出现协商失败或互操作性问题。
  • 只能使用基于数组的算法属性来创建新的 IKE 和 IPsec 策略。
  • 更新现有 IKE 或 IPsec 策略时,可能会在重新建立连接时暂时断开 VPN 通道。
  • 如果您的灾难恢复程序、自动化、脚本、API 集成或 CLI 工作流引用了已废弃的奇异属性,请对其进行相应更新。
  • 查看当前的 IKE 和 IPsec 策略,以确定使用的算法。
  • 验证对等 VPN 网关是否支持您计划在 IBM Cloud 上配置的算法。
  • 在更新 IBM Cloud VPN 网关之前,在对等 VPN 网关上为 IKE 和 IPsec 协商配置匹配算法。
  • 在维护窗口期间计划策略更新,以尽量减少服务中断。

了解 API 中的更新行为

应用程序接口会自动同步单数和基于数组的算法属性。 在更新政策之前,请检查以下行为和限制。

IKE 版本兼容性
基于数组的算法属性仅支持 IKEv2。 如果您使用 IKEv1,则必须使用单数属性为每个类别配置一个算法。
  • 对基于数组的属性使用 IKEv2:
{
   "ike_version": 2,
   "authentication_algorithms": ["sha512", "sha256"],
   "encryption_algorithms": ["aes256", "aes128"]
}
  • 在属性为单数时,请使用 IKEv1:
{
   "ike_version": 1,
   "authentication_algorithm": "sha256",
   "encryption_algorithm": "aes128"
}

IKEv1 每个类别只支持一种算法。 使用 IKEv1 的 VPN 连接不支持基于数组的 IKE 或 IPsec 算法属性。 尽可能使用 IKEv2。

自动同步
更新基于数组的属性 (authentication_algorithms, encryption_algorithms, dh_groups, pfs_groups) 时,相应的单数属性 (authentication_algorithm, encryption_algorithm, dh_group, pfs) 也会自动更新。 同样,更新奇异属性会自动更新相关的基于数组的属性。 有关例子,请参见
只读指示器
当配置了多个算法时,相关属性(authentication_algorithm、encryption_algorithm )会在 API 响应中返回只读指示值。 例如:
  • authentication_algorithm 返回项 "multiple"
  • encryption_algorithm 返回项 "multiple"
  • dh_group 返回项 65535

这些值只在响应中返回,不能在 PATCH 请求中提交。

{
   "authentication_algorithms": ["sha256", "sha384", "sha512"],
   "authentication_algorithm": "multiple",
   "dh_groups": [14, 15, 16],
   "dh_group": 65535,
   "encryption_algorithms": ["aes128", "aes256"],
   "encryption_algorithm": "multiple"
}

如果在基于数组的属性中仅配置了一个算法,则该单数属性将返回配置的值,而不是 "multiple"。

{
   "authentication_algorithms": ["sha256"],
   "authentication_algorithm": "sha256",
   "dh_groups": [14],
   "dh_group": 14,
   "encryption_algorithms": ["aes128"],
   "encryption_algorithm": "aes128"
}
财产混合限制
请勿在单个请求中混合使用同一算法类别的单一属性和基于数组的属性。 每个请求选择一种方法。
  • 正确示例此示例包括 IKE 的算法属性,所有类别都只使用基于数组的属性:
curl -X PATCH "$vpc_api_endpoint/v1/ike_policies/$ike_policy_id?version=$api_version&generation=2" \
   -H "Authorization: $iam_token" \
   -d '{
     "authentication_algorithms": ["sha256", "sha384", "sha512"],
     "dh_groups": [14, 15, 16],
     "encryption_algorithms": ["aes128", "aes256"]
   }'
  • 错误示例:该示例包括 IKE 的算法属性,其中同一类别中混合使用了基于单数和数组的属性:
curl -X PATCH "$vpc_api_endpoint/v1/ike_policies/$ike_policy_id?version=$api_version&generation=2" \
   -H "Authorization: $iam_token" \
   -d '{
     "authentication_algorithm": "sha512",
     "authentication_algorithms": ["sha256", "sha384", "sha512"],
     "dh_groups": [14, 15, 16],
     "encryption_algorithms": ["aes128", "aes256"]
   }'
GCM 算法要求和限制
如果 encryption_algorithms 属性包含基于 GCM 的算法(aes128gcm16、aes192gcm16 或 aes256gcm16 ),则 authentication_algorithms 属性必须设置为 ["disabled"]。
  • 正确示例:当 encryption_algorithms 数组包含基于 GCM 的算法时,显示IPsec算法的属性:
curl -X PATCH "$vpc_api_endpoint/v1/ipsec_policies/$ipsec_policy_id?version=$api_version&generation=2" \
   -H "Authorization: $iam_token" \
   -d '{
     "authentication_algorithms": ["disabled"],
     "encryption_algorithms": ["aes256gcm16", "aes192gcm16"],
     "pfs_groups": ["group_14", "group_15", "group_16"]
   }'
  • 错误示例:显示了IPsec的算法属性,其中 encryption_algorithms 数组包含基于 GCM 的算法:
curl -X PATCH "$vpc_api_endpoint/v1/ipsec_policies/$ipsec_policy_id?version=$api_version&generation=2" \
   -H "Authorization: $iam_token" \
   -d '{
     "authentication_algorithms": ["sha256"],
     "encryption_algorithms": ["aes256gcm16", "aes192gcm16"],
     "pfs_groups": ["group_14", "group_15", "group_16"]
   }'

GCM 算法提供加密和内置身份验证功能,作为单一操作的一部分。 不要配置单独的身份验证算法,如 sha256 或 sha512 与 GCM 加密算法。

请勿在同一策略中混合使用 GCM 和非 GCM 加密算法。 将它们混合使用可能会导致配置冲突和协商失败。

: 当 authentication_algorithms 设置为 ["disabled"] 时,若将加密算法从 GCM 更改为非 GCM 加密算法,还必须更新 authentication_algorithms。

  • 正确示例:同时更新 encryption_algorithms 和 authentication_algorithms 属性:
curl -X PATCH "$vpc_api_endpoint/v1/ipsec_policies/$ipsec_policy_id?version=$api_version&generation=2" \
   -H "Authorization: $iam_token" \
   -d '{
     "authentication_algorithms": ["sha512", "sha256"],
     "encryption_algorithms": ["aes256", "aes128"],
     "pfs_groups": ["group_14", "group_15", "group_16"]
   }'
  • 错误示例:示例中,只有 encryption_algorithms 属性使用非 GCM 算法更新 (aes128, aes192, aes256):
curl -X PATCH "$vpc_api_endpoint/v1/ipsec_policies/$ipsec_policy_id?version=$api_version&generation=2" \
   -H "Authorization: $iam_token" \
   -d '{
     "authentication_algorithms": ["disabled"],
     "encryption_algorithms": ["aes256", "aes128"],
     "pfs_groups": ["group_14", "group_15", "group_16"]
   }'
算法验证规则
确保请求中的所有算法值都有效、唯一且非空。 只使用支持的算法名称,避免重复,并在每个数组中至少提供一个值。 无效、重复或空条目会导致验证错误。
  • 正确示例更新算法值,所有类别都使用支持的算法和值:
{
   "authentication_algorithms": ["sha512", "sha256"],
   "dh_groups": [14, 15],
   "encryption_algorithms": ["aes256", "aes192", "aes128"]
}
  • 错误示例:更新算法值,在同一算法类别中使用重复值:
{
   "authentication_algorithms": ["sha512", "sha256"],
   "dh_groups": [14, 15],
   "encryption_algorithms": ["aes256", "aes256", "aes128"]
}

使用 API 更新 IKE 策略

请按照以下步骤将您的 IKE 策略从单一算法更新为多算法。

开始之前,请确保 设置好 API 环境。

要使用 API 更新 IKE 策略,请按照以下步骤操作:

  1. 例如,将 IKE 策略 ID 保存在一个变量中:

    export ike_policy_id=<your_ike_policy_id>
    

    要查找 IKE 策略 ID,请使用 列表 IKE 策略 命令。

  2. 更新 IKE 策略以使用多种算法。 用相应的数组属性替换单数属性。

    authentication_algorithms- 认证算法阵列。 选项:sha256, sha384, sha512。

    dh_groups- Diffie-Hellman 组阵列。 选项:14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 31。

    encryption_algorithms- 加密算法阵列。 选项:aes128, aes192, aes256。

    curl -X PATCH "$vpc_api_endpoint/v1/ike_policies/$ike_policy_id?version=$api_version&generation=2" \
      -H "Authorization: $iam_token" \
      -d '{
        "authentication_algorithms": ["sha256", "sha384", "sha512"],
        "dh_groups": [14, 15, 16],
        "encryption_algorithms": ["aes128", "aes256"]
      }'
    

IKE 策略更新示例

更新 IKE 策略中基于数组的属性 encryption_algorithms, authentication_algorithms,和 dh_groups 时,相应的奇异属性 encryption_algorithm, authentication_algorithm,和 dh_group 也会自动更新。 同样,当你更新任何奇异属性时,相关的基于数组的属性也会自动更新。

下面的示例展示了 PATCH 请求如何影响单属性和数组属性:

例 1:从单一算法到多种算法

  • 该示例显示了从单一算法到多种算法的修补行为。 当前状态显示单值属性 encryption_algorithm 设置为 aes128,基于数组的属性 encryption_algorithms 也只包含 aes128。

       {
       "authentication_algorithm": "sha256",
       "authentication_algorithms": [
          "sha256"
       ],
       "created_at": "2025-03-09T01:40:25.782663Z",
       "dh_group": 14,
       "dh_groups": [
          14
       ],
       "encryption_algorithm": "aes128",
       "encryption_algorithms": [
          "aes128"
       ],
       "id": "r006-e98f46a3-1e4e-4195-b4e5-b8155192689d",
       "ike_version": 2,
       "key_lifetime": 28800,
       "name": "my-ike-policy",
       "negotiation_mode": "main",
       "resource_group": {
          "id": "fee82deba12e4c0fb69c3b09d1f12345",
          "name": "Default"
       },
       "resource_type": "ike_policy"
       }
    
  • 在 PATCH 请求中,更新了基于数组的属性 encryption_algorithms,使其同时指定 aes128 和 aes256。

       {
       "encryption_algorithms": [
          "aes128",
          "aes256"
       ]
       }
    
  • 成功的响应如下例所示。 在此响应中,单数属性 encryption_algorithm 返回一个只读值 "multiple",表明当前已配置多个算法。 无法通过 PATCH 请求直接修改此字段。 基于数组的属性 encryption_algorithms 已更新,现同时包含 aes128 和 aes256。

       {
       "authentication_algorithm": "sha256",
       "authentication_algorithms": [
          "sha256"
       ],
       "created_at": "2025-03-09T01:40:25.782663Z",
       "dh_group": 14,
       "dh_groups": [
          14
       ],
       "encryption_algorithm": "multiple",
       "encryption_algorithms": [
          "aes128",
          "aes256"
       ],
       "id": "r006-e98f46a3-1e4e-4195-b4e5-b8155192689d",
       "ike_version": 2,
       "key_lifetime": 28800,
       "name": "my-ike-policy",
       "negotiation_mode": "main",
       "resource_group": {
          "id": "fee82deba12e4c0fb69c3b09d1f12345",
          "name": "Default"
       },
       "resource_type": "ike_policy"
       }
    

例 2:将多种算法转换为单一算法

  • 本例展示了从多种算法到单一算法的修补行为。 当前状态显示,单值属性 encryption_algorithm 已设置为 "multiple",而基于数组的属性 encryption_algorithms 包含 aes128 和 aes256。

       {
       "authentication_algorithm": "sha256",
       "authentication_algorithms": [
          "sha256"
       ],
       "created_at": "2025-03-09T01:40:25.782663Z",
       "dh_group": 14,
       "dh_groups": [
          14
       ],
       "encryption_algorithm": "multiple",
       "encryption_algorithms": [
          "aes128",
          "aes256"
       ],
       "id": "r006-e98f46a3-1e4e-4195-b4e5-b8155192689d",
       "ike_version": 2,
       "key_lifetime": 28800,
       "name": "my-ike-policy",
       "negotiation_mode": "main",
       "resource_group": {
          "id": "fee82deba12e4c0fb69c3b09d1f12345",
          "name": "Default"
       },
       "resource_type": "ike_policy"
       }
    
  • 在 PATCH 请求中,基于数组的属性 encryption_algorithms 已更新,现在只指定 aes256。

       {
       "encryption_algorithms": [
          "aes256"
       ]
       }
    
  • 成功的响应如下例所示。 在此响应中,单值属性 encryption_algorithm 会被自动设置为 aes256,这表明仅配置了一个算法。 基于数组的属性 encryption_algorithms 已更新,新增了 aes256。

       {
       "authentication_algorithm": "sha256",
       "authentication_algorithms": [
          "sha256"
       ],
       "created_at": "2025-03-09T01:40:25.782663Z",
       "dh_group": 14,
       "dh_groups": [
          14
       ],
       "encryption_algorithm": "aes256",
       "encryption_algorithms": [
          "aes256"
       ],
       "id": "r006-e98f46a3-1e4e-4195-b4e5-b8155192689d",
       "ike_version": 2,
       "key_lifetime": 28800,
       "name": "my-ike-policy",
       "negotiation_mode": "main",
       "resource_group": {
          "id": "fee82deba12e4c0fb69c3b09d1f12345",
          "name": "Default"
       },
       "resource_type": "ike_policy"
       }
    

使用 API 更新 IPsec 策略

请按照以下步骤将 IPsec 策略从单一算法属性更新为基于阵列的算法属性。

开始之前,请确保 设置好 API 环境。

要使用 API 更新 IPsec 策略,请按照以下步骤操作:

  1. 例如,在变量中存储 IPsec 策略 ID:

    export ipsec_policy_id=<your_ipsec_policy_id>
    

    要查找 IPsec 策略 ID,请使用 列表 IPsec 策略 命令。

  2. 更新 IPsec 策略以使用多种算法。 用相应的数组属性替换单数属性。

    authentication_algorithms- 认证算法阵列。 选项:sha256, sha384, sha512, disabled。

    encryption_algorithms- 加密算法阵列。 选项:aes128, aes192, aes256, aes128gcm16, aes192gcm16, aes256gcm16。

    pfs_groups- 完美前向保密组阵列。 选项:disabled, group_14, group_15, group_16, group_17, group_18, group_19, group_20, group_21, group_22, group_23, group_24, group_31.

    curl -X PATCH "$vpc_api_endpoint/v1/ipsec_policies/$ipsec_policy_id?version=$api_version&generation=2" \
      -H "Authorization: $iam_token" \
      -d '{
        "authentication_algorithms": ["sha256", "sha384", "sha512"],
        "encryption_algorithms": ["aes128", "aes256"],
        "pfs_groups": ["group_14", "group_15", "group_16"]
      }'
    

IPsec 策略更新示例

更新 IPsec 策略中基于数组的属性 encryption_algorithms, authentication_algorithms,和 pfs_groups 时,相应的单值属性 encryption_algorithm, authentication_algorithm,和 pfs 也会自动更新。 同样,当你更新任何单值属性时,相关的基于数组的属性也会自动更新。

下面的示例展示了 PATCH 请求如何影响单属性和数组属性:

例 1:从单一算法到多种算法

  • 该示例显示了从单一算法到多种算法的修补行为。 当前状态显示单值属性 encryption_algorithm 设置为 aes128,基于数组的属性 encryption_algorithms 也只包含 aes128。

       {
       "authentication_algorithm": "sha256",
       "authentication_algorithms": [
          "sha256"
       ],
       "connections": [],
       "created_at": "2025-03-09T01:46:00.785105Z",
       "encapsulation_mode": "tunnel",
       "encryption_algorithm": "aes128",
       "encryption_algorithms": [
          "aes128"
       ],
       "id": "r006-51eae621-dbbc-4c47-b623-b57a43c19876",
       "key_lifetime": 3600,
       "name": "my-ipsec-policy",
       "pfs": "group_14",
       "pfs_groups": [
          "group_14"
       ],
       "resource_group": {
          "id": "fee82deba12e4c0fb69c3b09d1f12345",
          "name": "Default"
       },
       "resource_type": "ipsec_policy",
       "transform_protocol": "esp"
       }
    
  • 在 PATCH 请求中,更新了基于数组的属性 encryption_algorithms,使其同时指定 aes128 和 aes256。

       {
       "encryption_algorithms": [
          "aes128",
          "aes256"
       ]
       }
    
  • 成功的响应如下例所示。 在此响应中,单值属性 encryption_algorithm 会被自动设置为只读值 "multiple",这表明当前已配置了多个算法。 无法通过 PATCH 请求直接修改此字段。 基于数组的属性 encryption_algorithms 现在同时包含 aes128 和 aes256。

       {
       "authentication_algorithm": "sha256",
       "authentication_algorithms": [
          "sha256"
       ],
       "connections": [],
       "created_at": "2025-03-09T01:46:00.785105Z",
       "encapsulation_mode": "tunnel",
       "encryption_algorithm": "multiple",
       "encryption_algorithms": [
          "aes128",
          "aes256"
       ],
       "id": "r006-51eae621-dbbc-4c47-b623-b57a43c19876",
       "key_lifetime": 3600,
       "name": "my-ipsec-policy",
       "pfs": "group_14",
       "pfs_groups": [
          "group_14"
       ],
       "resource_group": {
          "id": "fee82deba12e4c0fb69c3b09d1f12345",
          "name": "Default"
       },
       "resource_type": "ipsec_policy",
       "transform_protocol": "esp"
       }
    

例 2:将多种算法转换为单一算法

  • 本例展示了从多种算法到单一算法的修补行为。 当前状态显示,单值属性 encryption_algorithm 已设置为 "multiple",而基于数组的属性 encryption_algorithms 包含 aes128 和 aes256。

       {
       "authentication_algorithm": "sha256",
       "authentication_algorithms": [
          "sha256"
       ],
       "connections": [],
       "created_at": "2025-03-09T01:46:00.785105Z",
       "encapsulation_mode": "tunnel",
       "encryption_algorithm": "multiple",
       "encryption_algorithms": [
          "aes128",
          "aes256"
       ],
       "id": "r006-51eae621-dbbc-4c47-b623-b57a43c19876",
       "key_lifetime": 3600,
       "name": "my-ipsec-policy",
       "pfs": "group_14",
       "pfs_groups": [
          "group_14"
       ],
       "resource_group": {
          "id": "fee82deba12e4c0fb69c3b09d1f12345",
          "name": "Default"
       },
       "resource_type": "ipsec_policy",
       "transform_protocol": "esp"
       }
    
  • 在 PATCH 请求中,基于数组的属性 encryption_algorithms 已更新,现在只指定 aes256。

       {
       "encryption_algorithms": [
          "aes256"
       ]
       }
    
  • 成功的响应如下例所示。 在此响应中,单值属性 encryption_algorithm 会被自动设置为 aes256,这表明仅配置了一个算法。 基于数组的属性 encryption_algorithms 已更新,新增了 aes256。

        {
        "authentication_algorithm": "sha256",
        "authentication_algorithms": [
           "sha256"
        ],
        "connections": [],
        "created_at": "2025-03-09T01:46:00.785105Z",
        "encapsulation_mode": "tunnel",
        "encryption_algorithm": "aes256",
        "encryption_algorithms": [
           "aes256"
        ],
        "id": "r006-51eae621-dbbc-4c47-b623-b57a43c19876",
        "key_lifetime": 3600,
        "name": "my-ipsec-policy",
        "pfs": "group_14",
        "pfs_groups": [
           "group_14"
        ],
        "resource_group": {
           "id": "fee82deba12e4c0fb69c3b09d1f12345",
           "name": "Default"
        },
        "resource_type": "ipsec_policy",
        "transform_protocol": "esp"
        }