憑證提供 Web 伺服器證明其身分識別以及安全通道的機制。 憑證 API 對於建立透過 HTTPS 提供內容的網站至關重要。
GET/api/certificates/{id}
{
"alias": "My Self Signed Certificate",
"id": "{id}",
"issued_by": "CN=localhost",
"subject": "CN=localhost",
"thumbprint": "1E927A29E966FA11A7C469BC565A9E00B11F5F95",
"signature_algorithm": "sha256RSA",
"valid_from": "2017-04-12T11:26:26Z",
"valid_to": "2019-04-12T11:26:26Z",
"version": "3",
"intended_purposes": [
"Client Authentication",
"Server Authentication"
],
"private_key": {
"exportable": "false"
},
"subject_alternative_names": [
"DNS Name=localhost",
"DNS Name=my-work-pc"
],
"store": {
"name": "My",
"id": "{store-id}",
"_links": {
"self": {
"href": "/api/certificates/stores/{store-id}"
}
}
}
}
範圍要求
網頁伺服器擁有非常大量的憑證並不罕見。 為了改善這些伺服器的憑證 API 可用性,端點支援範圍要求。 將 HEAD 要求傳送至憑證端點時,會提示伺服器回應 X-Total-Count HTTP 標頭中可用的憑證總數。 接著,您可以在後續要求中設定 Range 標頭,以區塊方式要求憑證。
HEAD/api/certificates
200 OK
x-total-count: 100
將第二個和第三個憑證重新調整為100個
GET /api/certificates
Access-Token: Bearer {Access-Token}
Range: certificates=1-2
證書存儲
所有憑證都屬於證書存儲。 您可以從憑證儲存端點 /api/certificates/stores來取回可用的證書存儲清單。 這些證書存儲具有 宣告 屬性,指定存放區內憑證上允許哪些作業。 此存取可透過 應用程式設定 檔案的 certificates 區段進行設定。 目前證書存儲僅支援讀取作業。 未來 API 可能支援匯入、匯出、刪除和建立憑證。
GET/api/certificates/stores
{
"stores": [
{
"name": "My",
"id": "{store-id}",
"_links": {
"self": {
"href": "/api/certificates/stores/{store-id}"
}
}
},
{
"name": "WebHosting",
"id": "{store-id}"
// _links omitted
},
{
"name": "IIS Central Certificate Store",
"id": "{store-id}"
// _links omitted
}
]
}
列出特定存放區的憑證
憑證 API 支援依存放區篩選憑證。 若要這樣做,應重新處理目標證書存儲 標識子 屬性。 這可以透過證書存儲端點來完成。 然後,應該對指定查詢字串中 store.id 欄位的憑證端點提出要求。 下列要求會重新處理內建 Web 主控 證書存儲的所有憑證。
GET/api/certificates?store.id={store-id}
{
"certificates": [
{
"alias": "WebHostCert",
"id": "{cert-id}",
"issued_by": "CN=localhost",
"subject": "CN=localhost",
"thumbprint": "8E7933F41998C507B30F0E0AC8B548A903FE7843",
"valid_to": "2019-02-28T14:32:33Z",
"_links": {
"self": {
"href": "/api/certificates/{cert-id}"
}
}
}
]
}