@@ -56,7 +56,7 @@ func (k *PKI) Issue(role string, pkiopts PKIIssueOptions) (*PKIIssueResponse, er
56
56
57
57
type PKIGenerateIntermediateOptions struct {
58
58
CommonName string `json:"common_name"`
59
- KeyName string `json:"key_name"`
59
+ KeyName string `json:"key_name,omitempty "`
60
60
AltNames string `json:"alt_names,omitempty"`
61
61
Format string `json:"format,omitempty"`
62
62
PrivateKeyFormat string `json:"private_key_format,omitempty"`
@@ -100,6 +100,7 @@ type PKISignIntermediateOptions struct {
100
100
Format string `json:"format,omitempty"`
101
101
KeyUsage string `json:"key_usage,omitempty"`
102
102
UseCSRValues bool `json:"use_csr_values,omitempty"`
103
+ NotAfter string `json:"not_after,omitempty"`
103
104
}
104
105
105
106
type PKISignIntermediateResponse struct {
@@ -117,13 +118,111 @@ type PKISignIntermediateResponse struct {
117
118
118
119
func (k * PKI ) SignIntermediate (issuerRef string , pkiopts PKISignIntermediateOptions ) (* PKISignIntermediateResponse , error ) {
119
120
response := & PKISignIntermediateResponse {}
121
+ path := []string {"v1" , k .MountPoint }
122
+
123
+ if issuerRef == "" {
124
+ path = append (path , "root" , "sign-intermediate" )
125
+ } else {
126
+ path = append (path , "issuer" , issuerRef , "sign-intermediate" )
127
+ }
128
+
129
+ err := k .client .Write (path , pkiopts , response , nil )
130
+ if err != nil {
131
+ return nil , err
132
+ }
133
+
134
+ return response , nil
135
+ }
136
+
137
+ type PKIImportCABundleRequest struct {
138
+ PemBundle string `json:"pem_bundle"`
139
+ }
140
+ type PKIImportCABundleResponse struct {
141
+ Data struct {
142
+ ImportedIssuers []string `json:"imported_issuers"`
143
+ ImportedKeys []string `json:"imported_keys"`
144
+ Mapping map [string ]string `json:"mapping"`
145
+ ExistingIssuers []string `json:"existing_issuers"`
146
+ ExistingKeys []string `json:"existing_keys"`
147
+ } `json:"data"`
148
+ }
149
+
150
+ func (k * PKI ) ImportCaOrPrivateKey (pkiopts PKIImportCABundleRequest ) (* PKIImportCABundleResponse , error ) {
151
+ response := & PKIImportCABundleResponse {}
152
+ err := k .client .Write (
153
+ []string {
154
+ "v1" ,
155
+ k .MountPoint ,
156
+ "issuers" ,
157
+ "import" ,
158
+ "bundle" ,
159
+ }, pkiopts , response , nil ,
160
+ )
161
+ if err != nil {
162
+ return nil , err
163
+ }
164
+
165
+ return response , nil
166
+ }
167
+
168
+ type PKIListIssuersResponse struct {
169
+ Data struct {
170
+ KeyInfo map [string ]struct {
171
+ IssuerName string `json:"issuer_name"`
172
+ } `json:"key_info"`
173
+ Keys []string `json:"keys"`
174
+ } `json:"data"`
175
+ }
176
+
177
+ func (k * PKI ) ListIssuers () (* PKIListIssuersResponse , error ) {
178
+ response := & PKIListIssuersResponse {}
179
+ err := k .client .List (
180
+ []string {
181
+ "v1" ,
182
+ k .MountPoint ,
183
+ "issuers" ,
184
+ }, nil , response , nil ,
185
+ )
186
+ if err != nil {
187
+ return nil , err
188
+ }
189
+
190
+ return response , nil
191
+ }
192
+
193
+ type PKIUpdateIssuerRequest struct {
194
+ IssuerName string `json:"issuer_name"`
195
+ LeafNotAfterBehavior string `json:"leaf_not_after_behavior,omitempty"`
196
+ ManualChain []string `json:"manual_chain,omitempty"`
197
+ Usage []string `json:"usage,omitempty"`
198
+ }
199
+
200
+ type PKIUpdateIssuerResponse struct {
201
+ Data struct {
202
+ CACertificateChain []string `json:"ca_chain"`
203
+ Certificate string `json:"certificate"`
204
+ IssuerID string `json:"issuer_id"`
205
+ IssuerName string `json:"issuer_name"`
206
+ KeyID string `json:"key_id"`
207
+ LeafNotAfterBehavior string `json:"leaf_not_after_behavior"`
208
+ ManualChain interface {} `json:"manual_chain"`
209
+ Usage string `json:"usage"`
210
+ RevocationSignatureAlgorithm string `json:"revocation_signature_algorithm"`
211
+ IssuingCertificates []string `json:"issuing_certificates"`
212
+ CRLDistributionPoints []string `json:"crl_distribution_points"`
213
+ DeltaCRLDistributionPoints []string `json:"delta_crl_distribution_points"`
214
+ OCSPServers []string `json:"ocsp_servers"`
215
+ } `json:"data"`
216
+ }
217
+
218
+ func (k * PKI ) UpdateIssuer (issuerName string , pkiopts PKIUpdateIssuerRequest ) (* PKIUpdateIssuerResponse , error ) {
219
+ response := & PKIUpdateIssuerResponse {}
120
220
err := k .client .Write (
121
221
[]string {
122
222
"v1" ,
123
223
k .MountPoint ,
124
224
"issuer" ,
125
- issuerRef ,
126
- "sign-intermediate" ,
225
+ issuerName ,
127
226
}, pkiopts , response , nil ,
128
227
)
129
228
if err != nil {
@@ -132,3 +231,59 @@ func (k *PKI) SignIntermediate(issuerRef string, pkiopts PKISignIntermediateOpti
132
231
133
232
return response , nil
134
233
}
234
+
235
+ type PKIReadIssuerResponse struct {
236
+ Data struct {
237
+ CACertificateChain []string `json:"ca_chain"`
238
+ Certificate string `json:"certificate"`
239
+ RevocationTime int `json:"revocation_time"`
240
+ } `json:"data"`
241
+ }
242
+
243
+ func (k * PKI ) ReadIssuer (issuerName string ) (* PKIReadIssuerResponse , error ) {
244
+ response := & PKIReadIssuerResponse {}
245
+ err := k .client .Read (
246
+ []string {
247
+ "v1" ,
248
+ k .MountPoint ,
249
+ "issuer" ,
250
+ issuerName ,
251
+ "json" ,
252
+ }, response , nil ,
253
+ )
254
+ if err != nil {
255
+ return nil , err
256
+ }
257
+
258
+ return response , nil
259
+ }
260
+
261
+ type PKIRevokeIssuerResponse struct {
262
+ CAChain []string `json:"ca_chain"`
263
+ Certificate string `json:"certificate"`
264
+ IssuerID string `json:"issuer_id"`
265
+ IssuerName string "json:\" issuer_name\" "
266
+ KeyID string `json:"key_id"`
267
+ LeafNotAfterBehavior string `json:"leaf_not_after_behavior"`
268
+ ManualChain interface {} `json:"manual_chain"`
269
+ Usage string `json:"usage"`
270
+ RevocationTime int64 `json:"revocation_time"`
271
+ }
272
+
273
+ func (k * PKI ) RevokeIssuer (issuerName string ) (* PKIRevokeIssuerResponse , error ) {
274
+ response := & PKIRevokeIssuerResponse {}
275
+ err := k .client .Write (
276
+ []string {
277
+ "v1" ,
278
+ k .MountPoint ,
279
+ "issuer" ,
280
+ issuerName ,
281
+ "revoke" ,
282
+ }, nil , response , nil ,
283
+ )
284
+ if err != nil {
285
+ return nil , err
286
+ }
287
+
288
+ return response , nil
289
+ }
0 commit comments