Projekt

Obecné

Profil

Stáhnout (18.2 KB) Statistiky
| Větev: | Tag: | Revize:
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
    post:
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 used for creating the identity
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
          type: array
461
          items:
462
            type: string
463
            enum:
464
            - root
465
            - inter
466
            - end
467
        usage:
468
          type: array
469
          items:
470
            type: string
471
            enum:
472
            - CA
473
            - digitalSignature
474
            - authentication
475
            - SSL
476
        CN:
477
          type: string
478
          example: JMSD s.r.o.
479
        issuedby:
480
          type: integer
481
          example: 517
482
    Subject:
483
      required:
484
      - CN
485
      properties:
486
        C:
487
          type: string
488
          description: Country code
489
          example: CZ
490
        ST:
491
          type: string
492
          description: State/Province
493
          example: Pilsen Region
494
        L:
495
          type: string
496
          description: Locality
497
          example: Pilsen
498
        CN:
499
          type: string
500
          description: Common name
501
          example: Root CA s.r.o.
502
        O:
503
          type: string
504
          description: Organization
505
          example: Root CA s.r.o.
506
        OU:
507
          type: string
508
          description: Organization Unit
509
          example: IT department
510
        emailAddress:
511
          type: string
512
          description: Email Address
513
          example: root@ca.com
514
    Certificate:
515
      required:
516
      - notAfter
517
      - notBefore
518
      - status
519
      - subject
520
      - usage
521
      properties:
522
        subject:
523
          $ref: '#/components/schemas/Subject'
524
        notBefore:
525
          type: string
526
          format: date
527
          example: 2021-03-31
528
        notAfter:
529
          type: string
530
          format: date
531
          example: 2021-07-01
532
        usage:
533
          $ref: '#/components/schemas/CertificateUsage'
534
        CA:
535
          type: integer
536
          description: ID of the new item
537
          example: 547
538
        status:
539
          type: string
540
          enum:
541
          - valid
542
          - expired
543
          - revoked
544
    CertificateRequest:
545
      required:
546
      - subject
547
      - usage
548
      - validityDays
549
      properties:
550
        subject:
551
          $ref: '#/components/schemas/Subject'
552
        validityDays:
553
          type: integer
554
          example: 30
555
        usage:
556
          type: array
557
          items:
558
            type: string
559
            enum:
560
            - CA
561
            - authentication
562
            - digitalSignature
563
            - SSL
564
        CA:
565
          type: integer
566
          description: ID of the new item
567
          example: 547
568
        key:
569
          $ref: '#/components/schemas/PrivateKey'
570
        extensions:
571
          type: string
572
          example: subjectAltName=IP:192.168.7.1
573
    SuccessResponse:
574
      required:
575
      - data
576
      - success
577
      properties:
578
        success:
579
          type: boolean
580
          example: true
581
        data:
582
          type: string
583
          example: Operation was successfull
584
      description: Operation successfull
585
    CreatedResponse:
586
      required:
587
      - data
588
      - success
589
      properties:
590
        success:
591
          type: boolean
592
          example: true
593
        data:
594
          type: integer
595
          example: 457
596
      description: Item was created
597
    ErrorResponse:
598
      required:
599
      - data
600
      - success
601
      properties:
602
        success:
603
          type: boolean
604
          example: false
605
        data:
606
          type: string
607
          example: An error occured
608
    CertificateResponse:
609
      required:
610
      - data
611
      - success
612
      properties:
613
        success:
614
          type: boolean
615
          example: true
616
        data:
617
          $ref: '#/components/schemas/Certificate'
618
    PemResponse:
619
      required:
620
      - data
621
      - success
622
      properties:
623
        success:
624
          type: boolean
625
          example: true
626
        data:
627
          type: string
628
          description: Single PEM file or concatenation of multiple PEM formatted certificates
629
          example: '-----BEGIN CERTIFICATE-----...-----END CERTIFICATE-----'
630
    IdParameter:
631
      required:
632
      - id
633
      properties:
634
        id:
635
          type: integer
636
          example: 444
637
    SetStatusRequest:
638
      required:
639
      - status
640
      properties:
641
        status:
642
          type: string
643
          enum:
644
          - revoked
645
          - valid
646
        reason:
647
          type: string
648
          enum:
649
          - unspecified
650
          - keyCompromise
651
          - CACompromise
652
          - affiliationChanged
653
          - superseded
654
          - cessationOfOperation
655
          - certificateHold
656
          - removeFromCRL
657
    PrivateKey:
658
      properties:
659
        password:
660
          type: string
661
          example: passphrase
662
        key_pem:
663
          type: string
664
          example: '-----BEGIN PRIVATE_KEY-----...-----END PRIVATE_KEY-----'
665
    IdentityRequest:
666
      required:
667
      - name
668
      - password
669
      properties:
670
        name:
671
          type: string
672
          example: Jane Doe
673
        password:
674
          type: string
675
          example: passphrase
(3-3/3)