限制 TLS 版本

本页面介绍如何通过拒绝使用传输层安全协议 (TLS) 1.0 或 1.1 发出的请求来阻止对 Google Cloud 资源的访问。

概览

Google Cloud 支持多个 TLS 协议版本。为了满足合规性要求,您可能需要拒绝使用较低 TLS 版本的客户端发出的握手请求。为此,您可以使用 gcp.restrictTLSVersion 组织政策限制条件

gcp.restrictTLSVersion 限制条件可应用于资源层次结构中的组织、文件夹或项目。该限制条件使用拒绝列表,该列表拒绝明确的值并允许所有其他值。如果尝试使用许可名单,将会发生错误。

由于组织政策层次结构评估的行为,TLS 版本限制适用于指定的资源节点及其所有子节点。例如,如果您拒绝某个组织的 TLS 版本 1.0,则来自该组织的所有文件夹和项目(子级)的 TLS 版本也会被拒绝。

您可以通过更新子资源的组织政策来覆盖继承的 TLS 版本限制。例如,如果您的组织政策在组织级层拒绝 TLS 1.0,您可以通过对子文件夹设置单独的组织政策来移除对该文件夹的限制。如果该文件夹有任何子级,由于政策继承,文件夹的政策还将应用于每个子资源。

准备工作

  • 如需设置、更改或删除组织政策,您必须先获得 Organization Policy Administrator (roles/orgpolicy.policyAdmin) Identity and Access Management (IAM) 角色。

限制 TLS 版本

如需限制一个或多个 TLS 版本,请完成以下步骤:

控制台

  1. 在 Google Cloud 控制台中打开组织政策页面。

    转到“组织政策”

  2. 选择页面顶部的项目选择器。

  3. 从项目选择器中,选择您要设置组织政策的资源。

  4. 组织政策页面的列表中选择限制 TLS 版本限制条件。

  5. 如需更新此资源的组织政策,请点击修改

  6. 修改页面,选择自定义

  7. 强制执行下,选择强制执行选项:

    • 要合并和评估组织政策,请选择与父资源规则合并。如需详细了解继承与资源层次结构,请参阅了解层次结构评估

    • 如需覆盖从父资源继承的政策,请选择替换

  8. 点击添加规则

  9. 政策值下,默认值会设为全部拒绝。请改为选择自定义

  10. 政策类型下,选择拒绝

  11. 自定义值下方,输入要拒绝的 TLS 版本。以下值是有效的自定义值:

    • TLS_VERSION_1(适用于 TLS 1.0)
    • TLS_VERSION_1_1(适用于 TLS 1.1)

    如果您要限制多个 TLS 版本,请点击添加值,然后在其他字段中输入值。

  12. 要完成并应用组织政策,请点击保存

gcloud

使用 gcloud org-policies set-policy 命令为资源设置组织政策:

gcloud org-policies set-policy POLICY_PATH

POLICY_PATH 是组织政策文件的完整路径,如果使用 YAML 格式,该路径应如下所示:

name: RESOURCE_TYPE/RESOURCE_ID/policies/gcp.restrictTLSVersion
spec:
  rules:
  - values:
    deniedValues:
    - TLS_VERSION_1
    - TLS_VERSION_1_1

替换为以下内容:

  • RESOURCE_TYPEorganizationsfoldersprojects

  • RESOURCE_ID 是您的组织 ID、文件夹 ID、项目 ID 或项目编号,具体取决于在 RESOURCE_TYPE 中指定的资源类型。

运行以下命令以验证政策是否已应用:

gcloud org-policies describe gcp.restrictTLSVersion --RESOURCE_TYPE=RESOURCE_ID --effective

替换为以下内容:

  • RESOURCE_TYPEorganizationfolderproject

  • RESOURCE_ID 是您的组织 ID、文件夹 ID、项目 ID 或项目编号,具体取决于在 RESOURCE_TYPE 中指定的资源类型。

测试政策

您可以针对任何范围内的服务测试 TLS 版本限制条件。以下 curl 命令示例会验证 Cloud Storage 存储桶的 TLS 版本限制。

  curl -X GET -H "Authorization: Bearer $(gcloud auth print-access-token)" \
  "https://storage.googleapis.com/storage/v1/b/GCS_BUCKET_NAME/o" \
  --tlsvTLS_VERSION --tls-max TLS_VERSION --ciphers DEFAULT@SECLEVEL=0

--tlsv 和该值之间没有空格。例如 --tlsv1.1

替换为以下内容:

  • GCS_BUCKET_NAME 是项目中的 Cloud Storage 存储桶名称,例如 mybucketname

  • TLS_VERSION 是已配置政策中拒绝的 TLS 版本,如 1.01.1

以下示例 curl 请求显示 GCS_BUCKET_NAME 设置为 mybucketnameTLS_VERSION 设置为 1.1

  curl -X GET -H "Authorization: Bearer $(gcloud auth print-access-token)" \
  "https://storage.googleapis.com/storage/v1/b/mybucketname/o" \
  --tlsv1.1 --tls-max 1.1 --ciphers DEFAULT@SECLEVEL=0

如果组织政策配置为限制 TLS_VERSION_X,则在此示例命令中,任何尝试使用 TLS_VERSION_X 访问政策受限项目中的资源都将失败。系统将返回一条错误消息,说明失败的原因。

Request is disallowed by organization's constraints/gcp.restrictTLSVersion
constraint for 'projects/PROJECT_NUMBER' to use service
'SERVICE_NAME.googleapis.com' by violated TLS version `TLS_VERSION_X`

此输出包括以下值:

  • PROJECT_NUMBER:托管先前命令中引用的资源的项目编号。
  • SERVICE_NAME:被 TLS 限制政策屏蔽的范围内服务的名称。

支持的服务

以下服务支持 TLS 版本限制:

  • apigateway.googleapis.com
  • appengine.googleapis.com
  • artifactregistry.googleapis.com
  • assuredworkloads.googleapis.com
  • bigquery.googleapis.com
  • bigqueryreservation.googleapis.com
  • bigtableadmin.googleapis.com
  • binaryauthorization.googleapis.com
  • cloudasset.googleapis.com
  • cloudbuild.googleapis.com
  • clouddebugger.googleapis.com
  • cloudfunctions.googleapis.com
  • cloudkms.googleapis.com
  • cloudresourcemanager.googleapis.com
  • cloudscheduler.googleapis.com
  • cloudsearch.googleapis.com
  • cloudtasks.googleapis.com
  • cloudtrace.googleapis.com
  • composer.googleapis.com
  • compute.googleapis.com
  • container.googleapis.com
  • containeranalysis.googleapis.com
  • datacatalog.googleapis.com
  • dataflow.googleapis.com
  • datafusion.googleapis.com
  • datalabeling.googleapis.com
  • datamigration.googleapis.com
  • dataproc.googleapis.com
  • datastore.googleapis.com
  • deploymentmanager.googleapis.com
  • dialogflow.googleapis.com
  • discoveryengine.googleapis.com
  • dlp.googleapis.com
  • dns.googleapis.com
  • domains.googleapis.com
  • file.googleapis.com
  • firebaserules.googleapis.com
  • firestore.googleapis.com
  • genomics.googleapis.com
  • healthcare.googleapis.com
  • iam.googleapis.com
  • iamcredentials.googleapis.com
  • iap.googleapis.com
  • identitytoolkit.googleapis.com
  • jobs.googleapis.com
  • language.googleapis.com
  • lifesciences.googleapis.com
  • logging.googleapis.com
  • managedidentities.googleapis.com
  • memcache.googleapis.com
  • metastore.googleapis.com
  • ml.googleapis.com
  • monitoring.googleapis.com
  • networkmanagement.googleapis.com
  • notebooks.googleapis.com
  • osconfig.googleapis.com
  • policytroubleshooter.googleapis.com
  • privateca.googleapis.com
  • pubsub.googleapis.com
  • pubsublite.googleapis.com
  • recommender.googleapis.com
  • redis.googleapis.com
  • retail.googleapis.com
  • run.googleapis.com
  • runtimeconfig.googleapis.com
  • secretmanager.googleapis.com
  • servicecontrol.googleapis.com
  • servicedirectory.googleapis.com
  • servicenetworking.googleapis.com
  • sourcerepo.googleapis.com
  • spanner.googleapis.com
  • sqladmin.googleapis.com
  • storage.googleapis.com

  • storagetransfer.googleapis.com

  • sts.googleapis.com

  • texttospeech.googleapis.com

  • tpu.googleapis.com

  • videointelligence.googleapis.com

  • vision.googleapis.com

  • workflowexecutions.googleapis.com

  • workflows.googleapis.com

不支持的服务

TLS 版本限制组织政策限制条件不适用于以下服务:

  • App Engine (*.appspot.com)
  • Cloud Functions (*.cloudfunctions.net)、
  • Cloud Run (*.run.app)
  • Private Service Connect
  • 自定义网域

如需限制这些服务的 TLS 版本,请使用 Cloud Load Balancing 以及 SSL 政策。您还可以使用预定义的 constraints/compute.requireSslPolicy 限制条件和 SSL 政策的自定义限制条件,来对负载平衡器强制执行 TLS 版本和加密套件限制。

后续步骤