英文:
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='<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'
I am not familiar with go, but you can probably translate this command in go language with the client library.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论