1
|
openapi: 3.0.0
|
2
|
info:
|
3
|
title: X.509 certificate management
|
4
|
description: API for certificate management created for YOSO company
|
5
|
version: 1.1.0
|
6
|
servers:
|
7
|
- url: https://virtserver.swaggerhub.com/janpasek97/X509_management/1.1.0
|
8
|
description: X509 management API
|
9
|
tags:
|
10
|
- name: certificates
|
11
|
description: API for creating and querying certificates
|
12
|
paths:
|
13
|
/api/certificates:
|
14
|
get:
|
15
|
tags:
|
16
|
- certificates
|
17
|
summary: get list of certificates
|
18
|
description: Lists certificates based on provided filtering options
|
19
|
operationId: getCertificateList
|
20
|
parameters:
|
21
|
- name: filtering
|
22
|
in: query
|
23
|
description: Filter certificate type to be queried
|
24
|
required: false
|
25
|
style: form
|
26
|
explode: true
|
27
|
schema:
|
28
|
$ref: '#/components/schemas/Filtering'
|
29
|
responses:
|
30
|
"200":
|
31
|
description: returning results matching filtering criteria
|
32
|
content:
|
33
|
application/json:
|
34
|
schema:
|
35
|
$ref: '#/components/schemas/CertificateListResponse'
|
36
|
"400":
|
37
|
description: bad request
|
38
|
content:
|
39
|
application/json:
|
40
|
schema:
|
41
|
$ref: '#/components/schemas/ErrorResponse'
|
42
|
post:
|
43
|
tags:
|
44
|
- certificates
|
45
|
summary: create new certificate
|
46
|
description: Create a new certificate based on given information
|
47
|
operationId: createCertificate
|
48
|
requestBody:
|
49
|
description: Certificate data to be created
|
50
|
content:
|
51
|
application/json:
|
52
|
schema:
|
53
|
$ref: '#/components/schemas/CertificateRequest'
|
54
|
responses:
|
55
|
"201":
|
56
|
description: item created
|
57
|
content:
|
58
|
application/json:
|
59
|
schema:
|
60
|
$ref: '#/components/schemas/CreatedResponse'
|
61
|
"400":
|
62
|
description: invalid input, object invalid
|
63
|
content:
|
64
|
application/json:
|
65
|
schema:
|
66
|
$ref: '#/components/schemas/ErrorResponse'
|
67
|
/api/certificates/{id}:
|
68
|
get:
|
69
|
tags:
|
70
|
- certificates
|
71
|
summary: get certificate by ID
|
72
|
description: Get certificate in PEM format by ID
|
73
|
operationId: getCertificateById
|
74
|
parameters:
|
75
|
- name: id
|
76
|
in: path
|
77
|
description: ID of a certificate to be queried
|
78
|
required: true
|
79
|
style: simple
|
80
|
explode: false
|
81
|
schema:
|
82
|
$ref: '#/components/schemas/IdParameter'
|
83
|
responses:
|
84
|
"200":
|
85
|
description: returning the certificate
|
86
|
content:
|
87
|
application/json:
|
88
|
schema:
|
89
|
$ref: '#/components/schemas/PemResponse'
|
90
|
"404":
|
91
|
description: the certificate was not found
|
92
|
content:
|
93
|
application/json:
|
94
|
schema:
|
95
|
$ref: '#/components/schemas/ErrorResponse'
|
96
|
"400":
|
97
|
description: bad request
|
98
|
content:
|
99
|
application/json:
|
100
|
schema:
|
101
|
$ref: '#/components/schemas/ErrorResponse'
|
102
|
delete:
|
103
|
tags:
|
104
|
- certificates
|
105
|
summary: delete certificate by ID
|
106
|
description: Delete certificate by id. If the specified certificate is an issuer of some other certificate, whole subtree is delted.
|
107
|
operationId: deleteCertificateById
|
108
|
parameters:
|
109
|
- name: id
|
110
|
in: path
|
111
|
description: ID of a certificate to be deleted
|
112
|
required: true
|
113
|
style: simple
|
114
|
explode: false
|
115
|
schema:
|
116
|
$ref: '#/components/schemas/IdParameter'
|
117
|
responses:
|
118
|
"200":
|
119
|
description: certificate deleted
|
120
|
content:
|
121
|
application/json:
|
122
|
schema:
|
123
|
$ref: '#/components/schemas/SuccessResponse'
|
124
|
"400":
|
125
|
description: bad request
|
126
|
content:
|
127
|
application/json:
|
128
|
schema:
|
129
|
$ref: '#/components/schemas/ErrorResponse'
|
130
|
"404":
|
131
|
description: Certificate was not found
|
132
|
content:
|
133
|
application/json:
|
134
|
schema:
|
135
|
$ref: '#/components/schemas/ErrorResponse'
|
136
|
patch:
|
137
|
tags:
|
138
|
- certificates
|
139
|
summary: revoke certificate by id
|
140
|
description: Revoke a certificate specified by id
|
141
|
operationId: revokeCertificateById
|
142
|
parameters:
|
143
|
- name: id
|
144
|
in: path
|
145
|
description: ID of a certificate to be deleted
|
146
|
required: true
|
147
|
style: simple
|
148
|
explode: false
|
149
|
schema:
|
150
|
$ref: '#/components/schemas/IdParameter'
|
151
|
requestBody:
|
152
|
content:
|
153
|
application/json:
|
154
|
schema:
|
155
|
$ref: '#/components/schemas/SetStatusRequest'
|
156
|
responses:
|
157
|
"200":
|
158
|
description: Certificate status updated
|
159
|
content:
|
160
|
application/json:
|
161
|
schema:
|
162
|
$ref: '#/components/schemas/SuccessResponse'
|
163
|
"400":
|
164
|
description: bad request
|
165
|
content:
|
166
|
application/json:
|
167
|
schema:
|
168
|
$ref: '#/components/schemas/ErrorResponse'
|
169
|
"404":
|
170
|
description: Certificate was not found
|
171
|
content:
|
172
|
application/json:
|
173
|
schema:
|
174
|
$ref: '#/components/schemas/ErrorResponse'
|
175
|
/api/certificates/{id}/chain:
|
176
|
get:
|
177
|
tags:
|
178
|
- certificates
|
179
|
summary: get certificate's trust chain by ID
|
180
|
description: Get certificate trust chain in PEM format by ID
|
181
|
operationId: getCertificateTrustChainById
|
182
|
parameters:
|
183
|
- name: id
|
184
|
in: path
|
185
|
description: ID of a child certificate whose chain is to be queried
|
186
|
required: true
|
187
|
style: simple
|
188
|
explode: false
|
189
|
schema:
|
190
|
$ref: '#/components/schemas/IdParameter'
|
191
|
responses:
|
192
|
"200":
|
193
|
description: returning the trust chain
|
194
|
content:
|
195
|
application/json:
|
196
|
schema:
|
197
|
$ref: '#/components/schemas/PemResponse'
|
198
|
"404":
|
199
|
description: the certificate was not found
|
200
|
content:
|
201
|
application/json:
|
202
|
schema:
|
203
|
$ref: '#/components/schemas/ErrorResponse'
|
204
|
"400":
|
205
|
description: bad request
|
206
|
content:
|
207
|
application/json:
|
208
|
schema:
|
209
|
$ref: '#/components/schemas/ErrorResponse'
|
210
|
/api/certificates/{id}/root:
|
211
|
get:
|
212
|
tags:
|
213
|
- certificates
|
214
|
summary: get certificate's root of trust chain by ID
|
215
|
description: Get certificate's root of trust chain in PEM format by ID
|
216
|
operationId: getCertificateRootById
|
217
|
parameters:
|
218
|
- name: id
|
219
|
in: path
|
220
|
description: ID of a child certificate whose root is to be queried
|
221
|
required: true
|
222
|
style: simple
|
223
|
explode: false
|
224
|
schema:
|
225
|
$ref: '#/components/schemas/IdParameter'
|
226
|
responses:
|
227
|
"200":
|
228
|
description: returning the root of trust chain
|
229
|
content:
|
230
|
application/json:
|
231
|
schema:
|
232
|
$ref: '#/components/schemas/PemResponse'
|
233
|
"404":
|
234
|
description: the certificate was not found
|
235
|
content:
|
236
|
application/json:
|
237
|
schema:
|
238
|
$ref: '#/components/schemas/ErrorResponse'
|
239
|
"400":
|
240
|
description: bad request
|
241
|
content:
|
242
|
application/json:
|
243
|
schema:
|
244
|
$ref: '#/components/schemas/ErrorResponse'
|
245
|
/api/certificates/{id}/details:
|
246
|
get:
|
247
|
tags:
|
248
|
- certificates
|
249
|
summary: get certificate's details by ID
|
250
|
description: Get certificate details by ID
|
251
|
operationId: getCertificateDetailsById
|
252
|
parameters:
|
253
|
- name: id
|
254
|
in: path
|
255
|
description: ID of a certificate whose details are to be queried
|
256
|
required: true
|
257
|
style: simple
|
258
|
explode: false
|
259
|
schema:
|
260
|
$ref: '#/components/schemas/IdParameter'
|
261
|
responses:
|
262
|
"200":
|
263
|
description: returning the certificate details
|
264
|
content:
|
265
|
application/json:
|
266
|
schema:
|
267
|
$ref: '#/components/schemas/CertificateResponse'
|
268
|
"404":
|
269
|
description: the certificate was not found
|
270
|
content:
|
271
|
application/json:
|
272
|
schema:
|
273
|
$ref: '#/components/schemas/ErrorResponse'
|
274
|
"400":
|
275
|
description: bad request
|
276
|
content:
|
277
|
application/json:
|
278
|
schema:
|
279
|
$ref: '#/components/schemas/ErrorResponse'
|
280
|
/api/certificates/{id}/publickey:
|
281
|
get:
|
282
|
tags:
|
283
|
- certificates
|
284
|
summary: get public key of given certificate
|
285
|
description: Get public key that belongs to the selected certificate
|
286
|
operationId: getPublicKeyOfCertificateById
|
287
|
parameters:
|
288
|
- name: id
|
289
|
in: path
|
290
|
description: ID of a certificate whose public key is to be queried
|
291
|
required: true
|
292
|
style: simple
|
293
|
explode: false
|
294
|
schema:
|
295
|
$ref: '#/components/schemas/IdParameter'
|
296
|
responses:
|
297
|
"200":
|
298
|
description: returning the certificate's public key
|
299
|
content:
|
300
|
application/json:
|
301
|
schema:
|
302
|
$ref: '#/components/schemas/PemResponse'
|
303
|
"404":
|
304
|
description: the certificate was not found
|
305
|
content:
|
306
|
application/json:
|
307
|
schema:
|
308
|
$ref: '#/components/schemas/ErrorResponse'
|
309
|
"400":
|
310
|
description: bad request
|
311
|
content:
|
312
|
application/json:
|
313
|
schema:
|
314
|
$ref: '#/components/schemas/ErrorResponse'
|
315
|
/api/certificates/{id}/privatekey:
|
316
|
get:
|
317
|
tags:
|
318
|
- certificates
|
319
|
summary: get private key of given certificate
|
320
|
description: Get private key that belongs to the selected certificate
|
321
|
operationId: getPrivateKeyOfCertificateById
|
322
|
parameters:
|
323
|
- name: id
|
324
|
in: path
|
325
|
description: ID of a certificate whose private key is to be queried
|
326
|
required: true
|
327
|
style: simple
|
328
|
explode: false
|
329
|
schema:
|
330
|
$ref: '#/components/schemas/IdParameter'
|
331
|
responses:
|
332
|
"200":
|
333
|
description: returning the certificate's private key
|
334
|
content:
|
335
|
application/json:
|
336
|
schema:
|
337
|
$ref: '#/components/schemas/PemResponse'
|
338
|
"404":
|
339
|
description: the certificate was not found
|
340
|
content:
|
341
|
application/json:
|
342
|
schema:
|
343
|
$ref: '#/components/schemas/ErrorResponse'
|
344
|
"400":
|
345
|
description: bad request
|
346
|
content:
|
347
|
application/json:
|
348
|
schema:
|
349
|
$ref: '#/components/schemas/ErrorResponse'
|
350
|
components:
|
351
|
schemas:
|
352
|
CAUsage:
|
353
|
required:
|
354
|
- CA
|
355
|
- SSL
|
356
|
- authentication
|
357
|
- digitalSignature
|
358
|
properties:
|
359
|
CA:
|
360
|
type: boolean
|
361
|
authentication:
|
362
|
type: boolean
|
363
|
digitalSignature:
|
364
|
type: boolean
|
365
|
SSL:
|
366
|
type: boolean
|
367
|
IssuerListItem:
|
368
|
required:
|
369
|
- CN
|
370
|
- id
|
371
|
properties:
|
372
|
id:
|
373
|
type: integer
|
374
|
example: 547
|
375
|
CN:
|
376
|
type: string
|
377
|
example: Root CA s.r.o.
|
378
|
CertificateListResponse:
|
379
|
properties:
|
380
|
success:
|
381
|
type: boolean
|
382
|
example: true
|
383
|
data:
|
384
|
type: array
|
385
|
items:
|
386
|
$ref: '#/components/schemas/CertificateListItem'
|
387
|
CertificateListItem:
|
388
|
properties:
|
389
|
id:
|
390
|
type: integer
|
391
|
example: 547
|
392
|
CN:
|
393
|
type: string
|
394
|
example: Root CA s.r.o.
|
395
|
notBefore:
|
396
|
type: string
|
397
|
format: date
|
398
|
example: 2021-03-31
|
399
|
notAfter:
|
400
|
type: string
|
401
|
format: date
|
402
|
example: 2021-07-01
|
403
|
usage:
|
404
|
$ref: '#/components/schemas/CAUsage'
|
405
|
issuer:
|
406
|
$ref: '#/components/schemas/IssuerListItem'
|
407
|
Filtering:
|
408
|
properties:
|
409
|
CA:
|
410
|
type: boolean
|
411
|
issuedby:
|
412
|
type: integer
|
413
|
example: 517
|
414
|
Subject:
|
415
|
required:
|
416
|
- CN
|
417
|
properties:
|
418
|
C:
|
419
|
type: string
|
420
|
description: Country code
|
421
|
example: CZ
|
422
|
ST:
|
423
|
type: string
|
424
|
description: State/Province
|
425
|
example: Pilsen Region
|
426
|
L:
|
427
|
type: string
|
428
|
description: Locality
|
429
|
example: Pilsen
|
430
|
CN:
|
431
|
type: string
|
432
|
description: Common name
|
433
|
example: Root CA s.r.o.
|
434
|
O:
|
435
|
type: string
|
436
|
description: Organization
|
437
|
example: Root CA s.r.o.
|
438
|
OU:
|
439
|
type: string
|
440
|
description: Organization Unit
|
441
|
example: IT department
|
442
|
emailAddress:
|
443
|
type: string
|
444
|
description: Email Address
|
445
|
example: root@ca.com
|
446
|
Certificate:
|
447
|
required:
|
448
|
- notAfter
|
449
|
- notBefore
|
450
|
- subject
|
451
|
- usage
|
452
|
properties:
|
453
|
subject:
|
454
|
$ref: '#/components/schemas/Subject'
|
455
|
notBefore:
|
456
|
type: string
|
457
|
format: date
|
458
|
example: 2021-03-31
|
459
|
notAfter:
|
460
|
type: string
|
461
|
format: date
|
462
|
example: 2021-07-01
|
463
|
usage:
|
464
|
$ref: '#/components/schemas/CAUsage'
|
465
|
CA:
|
466
|
type: integer
|
467
|
description: ID of the new item
|
468
|
example: 547
|
469
|
CertificateRequest:
|
470
|
required:
|
471
|
- subject
|
472
|
- usage
|
473
|
- validityDays
|
474
|
properties:
|
475
|
subject:
|
476
|
$ref: '#/components/schemas/Subject'
|
477
|
validityDays:
|
478
|
type: integer
|
479
|
example: 30
|
480
|
usage:
|
481
|
type: array
|
482
|
items:
|
483
|
type: string
|
484
|
enum:
|
485
|
- CA
|
486
|
- authentication
|
487
|
- digitalSignature
|
488
|
- SSL
|
489
|
CA:
|
490
|
type: integer
|
491
|
description: ID of the new item
|
492
|
example: 547
|
493
|
SuccessResponse:
|
494
|
required:
|
495
|
- data
|
496
|
- success
|
497
|
properties:
|
498
|
success:
|
499
|
type: boolean
|
500
|
example: true
|
501
|
data:
|
502
|
type: string
|
503
|
example: Operation was successfull
|
504
|
description: Operation successfull
|
505
|
CreatedResponse:
|
506
|
required:
|
507
|
- data
|
508
|
- success
|
509
|
properties:
|
510
|
success:
|
511
|
type: boolean
|
512
|
example: true
|
513
|
data:
|
514
|
type: integer
|
515
|
example: 457
|
516
|
description: Item was created
|
517
|
ErrorResponse:
|
518
|
required:
|
519
|
- data
|
520
|
- success
|
521
|
properties:
|
522
|
success:
|
523
|
type: boolean
|
524
|
example: false
|
525
|
data:
|
526
|
type: string
|
527
|
example: An error occured
|
528
|
CertificateResponse:
|
529
|
required:
|
530
|
- data
|
531
|
- success
|
532
|
properties:
|
533
|
success:
|
534
|
type: boolean
|
535
|
example: true
|
536
|
data:
|
537
|
$ref: '#/components/schemas/Certificate'
|
538
|
PemResponse:
|
539
|
required:
|
540
|
- data
|
541
|
- success
|
542
|
properties:
|
543
|
success:
|
544
|
type: boolean
|
545
|
example: true
|
546
|
data:
|
547
|
type: string
|
548
|
description: Single PEM file or concatenation of multiple PEM formatted certificates
|
549
|
example: '-----BEGIN CERTIFICATE-----MIICLDCCAdKgAwIBAgIBADAKBggqhkjOPQQDAjB9MQswCQYDVQQGEwJCRTEPMA0GA1UEChMGR251VExTMSUwIwYDVQQ...etc-----END CERTIFICATE-----'
|
550
|
IdParameter:
|
551
|
required:
|
552
|
- id
|
553
|
properties:
|
554
|
id:
|
555
|
type: integer
|
556
|
example: 444
|
557
|
SetStatusRequest:
|
558
|
required:
|
559
|
- status
|
560
|
properties:
|
561
|
status:
|
562
|
type: string
|
563
|
enum:
|
564
|
- revoked
|
565
|
- valid
|
566
|
reason:
|
567
|
type: string
|
568
|
enum:
|
569
|
- unspecified
|
570
|
- keyCompromise
|
571
|
- CACompromise
|
572
|
- affiliationChanged
|
573
|
- superseded
|
574
|
- cessationOfOperation
|
575
|
- certificateHold
|
576
|
- removeFromCRL
|