对证书进行排序和过滤
本页面介绍如何对 Certificate Authority Service 中的 ListCertificates
API 调用返回的证书进行排序和过滤。
排序支持
默认情况下,ListCertificates
API 调用会返回按 create_time
字段排序的证书,最新的证书列在最前面。不能指定其他排序顺序。
过滤支持
以下字段可用于过滤 ListCertificates
API 调用返回的证书:
(https://google.aip.dev/160#has-operator)
注意:certificate_description.x509_description.key_usage.extended_key_usage.client_auth 和 certificate_description.x509_description.key_usage.extended_key_usage.server_auth 字段是布尔值,表示是否存在相应的扩展密钥用途。
过滤语法
过滤语法遵循 AIP 160 中设置的 API 过滤指南,但存在以下限制:
仅支持顶级
AND
运算符。所有其他运算符均不包含(例如OR
、NOT
、嵌套运算符或这些运算符的任意组合)。有效:过滤器仅使用顶级 AND 运算符:
create_time>"2020-08-21T11:30:00.11-05:00" AND certificate_description.x509_description.key_usage.extended_key_usage.server_auth=true
无效:过滤条件使用 OR 运算符:
create_time>"2020-08-21T11:30:00.11-05:00" OR certificate_description.x509_description.key_usage.extended_key_usage.server_auth=true
无效:过滤条件使用了嵌套运算符:
(create_time>"2020-08-21T11:30:00.11-05:00" AND certificate_description.x509_description.key_usage.extended_key_usage.server_auth=true) AND certificate_description.subject_description.subject.common_name="foo.com"
不支持通配符匹配(使用
*
),但certificate_description.subject_description.subject_alt_name.dns_names
字段(支持对 DNS 标签进行后缀匹配)除外。有效:过滤条件会比较通配符后缀匹配:
certificate_description.subject_description.subject_alt_name.dns_names:"*.foo.com"
无效:过滤条件与通配符前缀匹配的比较结果:
certificate_description.subject_description.subject_alt_name.dns_names:"foo.*"
无效:对于不受支持的字段,过滤条件会使用通配符来比较:
"certificate_description.subject_description.hex_serial_number"="*3d3"
后续步骤
- 了解如何申请证书。
- 了解如何撤消证书。
- 请参阅 REST API 参考文档。
- 请参阅 RPC API 参考文档。