从Golang代码或gcloud中查找使用特定SSL证书的目标HTTPS代理。

huangapple go评论67阅读模式
英文:

Find which target-https-proxies are using specific ssl-certificate on Google Cloud from Golang code or gcloud

问题

让我们假设我只能访问一些Google Cloud项目。证书是全局的。如何验证ssl证书是否未被使用?证书可能在我无法访问的其他项目中使用。

唯一的选择是 gcloud compute ssl-certificates delete certificate_name 吗?

只有当没有其他资源(例如目标HTTPS代理)引用SSL证书时,才能删除SSL证书。

好的,我可以尝试删除它,但是没有办法知道哪个目标HTTPS代理在使用它吗?

在官方文档 https://cloud.google.com/compute/docs/reference/rest/v1/targetHttpsProxies/setSslCertificates 中是否有任何字段可以帮助?


我需要知道是否可以使用Golang来实现这个功能。

英文:

Let's assume I do have access only to some Google Cloud projects. The certificate is global. How can I verify if ssl-certificate is not in use? Certificate can be used in other projects where I do not have access to.

Is the only one option gcloud compute ssl-certificates delete certificate_name?

> SSL certificates can only be deleted when no other resources (for example, target HTTPS proxies) refer to them.

Okay, I can try to delete it, but is there no way to know what Target HTTPS Proxy using it?

Is there any field that could help from official docs https://cloud.google.com/compute/docs/reference/rest/v1/targetHttpsProxies/setSslCertificates ?


I need to know if it is possible to do using Golang.

答案1

得分: 1

使用Cloud Asset API,您可以在过滤选项中列出使用特定SSL证书的所有目标HTTPS代理。例如,这里我们列出组织中使用特定证书的所有目标HTTPS代理:

gcloud asset list --organization='<MY ORGANIZATION ID>' \
  --billing-project='<MY BILLING PROJECT ID>' \
  --snapshot-time=$NOW \
  --filter="resource.data.sslCertificates:<MY SSL CERTIFICATE SELF LINK>" \
  --asset-types='compute.googleapis.com/TargetHttpsProxy' \
  --content-type='resource'

我不熟悉Go语言,但您可以使用客户端库将此命令转换为Go语言。

英文:

Using the Cloud Asset API, you could list all Target HTTPS Proxies using a specific ssl certificate within the filter option. For example, here we list all Target HTTPS Proxies in an organisation using a specific certificate:

gcloud asset list --organization=&#39;&lt;MY ORGANIZATION ID&gt;&#39; \
  --billing-project=&#39;&lt;MY BILLING PROJECT ID&gt;&#39; \
  --snapshot-time=$NOW \
  --filter=&quot;resource.data.sslCertificates:&lt;MY SSL CERTIFICATE SELF LINK&gt;&quot; \
  --asset-types=&#39;compute.googleapis.com/TargetHttpsProxy&#39; \
  --content-type=&#39;resource&#39;

I am not familiar with go, but you can probably translate this command in go language with the client library.

huangapple
  • 本文由 发表于 2023年3月27日 02:57:25
  • 转载请务必保留本文链接:https://go.coder-hub.com/75849891.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定