-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcertificates.go
173 lines (153 loc) · 6.06 KB
/
certificates.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
package horizon
import (
"fmt"
"strings"
)
// Certificates
type Module string
const (
WebRA Module = "webra"
Scep Module = "scep"
Est Module = "est"
Acme Module = "acme"
AcmeExternal Module = "acme-external"
)
type RevocationReason string
const (
Unspecified RevocationReason = "UNSPECIFIED"
KeyCompromise RevocationReason = "KEYCOMPROMISE"
CACompromise RevocationReason = "CACOMPROMISE"
AffiliationChanged RevocationReason = "AFFILIATIONCHANGED"
Superseded RevocationReason = "SUPERSEDED"
CessationOfOperation RevocationReason = "CESSATIONOFOPERATION"
)
func ValidateRevocationReason(reason string) (RevocationReason, error) {
uppered := strings.ToUpper(reason)
switch RevocationReason(uppered) {
case Unspecified:
return Unspecified, nil
case KeyCompromise:
return KeyCompromise, nil
case CACompromise:
return CACompromise, nil
case AffiliationChanged:
return AffiliationChanged, nil
case Superseded:
return Superseded, nil
case CessationOfOperation:
return CessationOfOperation, nil
default:
return "", fmt.Errorf("invalid revocation reason '%s'", reason)
}
}
type Label struct {
Key string `json:"key"`
Value string `json:"value"`
}
type Metadata struct {
Key string `json:"key"`
Value string `json:"value"`
}
type ThirdPartyItem struct {
Connector string `json:"connector"`
Id string `json:"id"`
Fingerprint string `json:"fingerprint,omitempty"`
PushDate int `json:"pushDate,omitempty"`
RemoveDate int `json:"removeDate,omitempty"`
}
// DiscoveredTLSPorts is the struct that contains the ports
type DiscoveredTLSPorts struct {
Port int `json:"port,omitempty"`
Version string `json:"version,omitempty"`
}
// DiscoveryData is the struct of the locally discovered certs metadata
type DiscoveryData struct {
CertificateLocation []string `json:"paths,omitempty"`
CertificateUsageLocation []string `json:"usages,omitempty"`
OS []string `json:"operatingSystems,omitempty"`
Hostname []string `json:"hostnames,omitempty"`
IP string `json:"ip,omitempty"`
Source []string `json:"sources,omitempty"`
TLSPorts []DiscoveredTLSPorts `json:"tlsPorts,omitempty"`
}
type DiscoveryInfo struct {
Campaign string `json:"campaign"`
LastDiscoveryDate int `json:"lastDiscoveryDate"`
Identifier string `json:"identifier,omitempty"`
}
type TriggerResultStatus string
const (
TriggerResultStatusSuccess TriggerResultStatus = "success"
TriggerResultStatusFailure TriggerResultStatus = "failure"
)
type TriggerResult struct {
Name string `json:"name,omitempty"`
Event string `json:"event,omitempty"`
TriggerType string `json:"triggerType,omitempty"`
LastExecutionDate int `json:"lastExecutionDate,omitempty"`
Status TriggerResultStatus `json:"status,omitempty"`
Detail string `json:"detail,omitempty"`
Retryable bool `json:"retryable,omitempty"`
}
type Certificate struct {
Id string `json:"_id,omitempty"`
Module string `json:"module"`
Profile string `json:"profile,omitempty"`
Owner string `json:"owner,omitempty"`
Team string `json:"team,omitempty"`
ContactEmail string `json:"contactEmail,omitempty"`
Certificate string `json:"certificate"`
Thumbprint string `json:"thumbprint"`
SelfSigned bool `json:"selfSigned"`
PublicKeyThumbprint string `json:"publicKeyThumbprint"`
Dn string `json:"dn"`
Serial string `json:"serial"`
Issuer string `json:"issuer"`
NotBefore int `json:"notBefore"`
NotAfter int `json:"notAfter"`
RevocationDate int `json:"revocationDate,omitempty"`
RevocationReason RevocationReason `json:"revocationReason,omitempty"`
KeyType string `json:"keyType"`
SigningAlgorithm string `json:"signingAlgorithm"`
Revoked bool `json:"revoked"`
ThirdPartyData []ThirdPartyItem `json:"thirdPartyData,omitempty"`
TriggerResults []TriggerResult `json:"triggerResults,omitempty"`
DiscoveryData []DiscoveryData `json:"discoveryData,omitempty"`
DiscoveryInfo []DiscoveryInfo `json:"discoveryInfo,omitempty"`
DiscoveryTrusted *bool `json:"discoveryTrusted,omitempty"`
Labels []Label `json:"labels,omitempty"`
SubjectAlternateNames []struct {
SanType string `json:"sanType"`
Value string `json:"value"`
} `json:"subjectAlternateNames"`
Metadata []Metadata `json:"metadata"`
HolderId string `json:"holderId"`
}
type CertificateResponse struct {
Certificate Certificate `json:"certificate"`
}
type CertificateSearchQuery struct {
Query string `json:"query,omitempty"`
Fields []string `json:"fields,omitempty"`
SortedBy []SortFields `json:"sortedBy,omitempty"`
PageIndex int `json:"pageIndex,omitempty"`
PageSize int `json:"pageSize,omitempty"`
WithCount bool `json:"withCount,omitempty"`
}
type CertificateSearchResult struct {
Id string `json:"_id,omitempty"`
Module string `json:"module"`
Dn string `json:"dn"`
Serial string `json:"serial"`
NotAfter int `json:"notAfter"`
Permissions struct {
Revoke bool `json:"revoke"`
RequestRevoke bool `json:"requestRevoke"`
Update bool `json:"update"`
RequestUpdate bool `json:"requestUpdate"`
Recover bool `json:"recover"`
RequestRecover bool `json:"requestRecover"`
Migrate bool `json:"migrate"`
RequestMigrate bool `json:"requestMigrate"`
} `json:"permissions"`
}