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