如何像在门户中一样通过 SL api 获取加密密钥?

How can I get crypto keys via SL api as in portal?

我正在尝试像 portal 一样获取加密密钥,但我无法让我的掩码工作,有人可以告诉我以下请求有什么问题吗,顺便说一句,我正在使用以下 url

https://sldn.softlayer.com/reference/services/softlayer_security_certificate_request/getsslcertificaterequests

和 jic python api 使用了客户端,其余请求也可以为我工作以获取套接字层。

mask = "mask[accountId, certificateSigningRequest, certificateAuthorityName, id]

response = client['SoftLayer_Security_Certificate_Request'].getsslcertificaterequests()

我还想了解如何搜索与证书相关联的虚拟 ip,但我没有找到我需要的 api 方法。

您当前的代码将仅检索其中一个证书,而不是存储的安全证书,为了使您的掩码正常工作,您需要添加带有 " 双引号的字符串,您调用的方法应该是 getSslCertificateRequests,见下文:

accountId = 202768 #change this value
mask = "mask[accountId, certificateSigningRequest, certificateAuthorityName, id]"
response = client['SoftLayer_Security_Certificate_Request'].getSslCertificateRequests(accountId)

目前门户使用 SoftLayer_Account::getSecurityCertificate 检索存储的安全证书,包括 SSL,使用以下 Python 脚本:

import SoftLayer
from pprint import pprint as pp

USERNAME = 'set-me'
# Endpoint url that contains all the Api Services.   
API_KEY = 'set-me'
# Generate one for you or your users, or view yours at 
https://control.softlayer.com/account/users


client = SoftLayer.create_client_from_env(username=USERNAME,
                                      api_key=API_KEY)

accountService = client['SoftLayer_Account']

try:
""""
getSecurityCertificates() retrieves stored security certificates (ie. SSL)
"""""
result = accountService.getSecurityCertificates()
pp(result)

except SoftLayer.SoftLayerAPIError as e:
""""
If there was an error returned from the SoftLayer API then bomb out with the
error message.
"""""
print("Unable to retrieve the Account's stored security certificates (i.e. SSL) . %s %s " % (e.faultCode, e.faultString))

要找到关联的虚拟 ip 地址,您应该使用方法 getAdcLoadBalancers 并发送在前面的方法中获得的 id 值,试试这个 Rest 请求。

https://[username]:[apiKey]@api.softlayer.com/rest/v3.1/SoftLayer_Account/getAdcLoadBalancers?objectFilter={"adcLoadBalancers":{"securityCertificateId":{"operation":[id]}}}

记得更改 usernameapiKey 以获得有效凭据,以及提到的 id上面检索关联的负载均衡器 IP 地址。