-
Notifications
You must be signed in to change notification settings - Fork 5
/
jamfproapi_certificate_authority.go
56 lines (44 loc) · 2.19 KB
/
jamfproapi_certificate_authority.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
// jamfproapi_certificate_authority.go
// Jamf Pro Api - Certificate Authority Information
// api reference: https://developer.jamf.com/jamf-pro/reference/get_v1-pki-certificate-authority-active
// Jamf Pro API requires the structs to support a JSON data structure.
package jamfpro
import (
"fmt"
)
const uriCertificateAuthority = "/api/v1/pki/certificate-authority"
// Response
// ResponseActiveCertificateAuthority represents the JSON response for the active certificate authority.
type ResponseActiveCertificateAuthority struct {
SubjectX500Principal string `json:"subjectX500Principal"`
IssuerX500Principal string `json:"issuerX500Principal"`
SerialNumber string `json:"serialNumber"`
Version int `json:"version"`
NotAfter int64 `json:"notAfter"`
NotBefore int64 `json:"notBefore"`
Signature ActiveCertificateAuthoritySubsetSignature `json:"signature"`
KeyUsage []string `json:"keyUsage"`
KeyUsageExtended []string `json:"keyUsageExtended"`
SHA1Fingerprint string `json:"sha1Fingerprint"`
SHA256Fingerprint string `json:"sha256Fingerprint"`
}
// Subsets
type ActiveCertificateAuthoritySubsetSignature struct {
Algorithm string `json:"algorithm"`
AlgorithmOID string `json:"algorithmOid"`
Value string `json:"value"`
}
// CRUD
// GetActiveCertificateAuthority retrieves the active certificate authority details.
func (c *Client) GetActiveCertificateAuthority() (*ResponseActiveCertificateAuthority, error) {
endpoint := fmt.Sprintf("%s/active", uriCertificateAuthority)
var certAuth ResponseActiveCertificateAuthority
resp, err := c.HTTP.DoRequest("GET", endpoint, nil, &certAuth)
if err != nil {
return nil, fmt.Errorf(errMsgFailedGet, "certificate authority", err)
}
if resp != nil && resp.Body != nil {
defer resp.Body.Close()
}
return &certAuth, nil
}