Projekt

Obecné

Profil

Iteration 4 » Historie » Verze 9

Jan Pašek, 2021-04-08 07:55

1 1 Jan Pašek
h1. Iteration 4
2 2 Jan Pašek
3
*Target:* CRL/OCSP, certificate detailed view
4
5
h2. Tasks
6
7 5 Jan Pašek
h3. Implement certificate revocation, add CRL distribution point and OCSP endpoint to certificate extensions
8
9 9 Jan Pašek
* One Rest API endpoint: POST /api/certificates/{id}/revoke body =  { reason: "<reason for revocation>"} 
10 6 Jan Pašek
with reason: [unspecified, keyCompromise, cACompromise, affiliationChanged, superseded, cessationOfOperation, certificateHold, removeFromCRL, privilegeWithdrawn, aACompromise].
11
The reason will be optional and if not present, unspecified is used. 
12
* Controller will call a method revoke_certificate(id) of CertificateService.
13
* Certificate service will call a CertificateRepository set_certificate_revoked(id, timestamp, reason) to set the certificate revoked.
14
* Database must be extended with the following data: revocation date (Unix timestamp, generated automatically by the CertificateService), bool flag if is revoked, the reason for revocation(may be implemented as a second table with revocation reason values).
15
* CertificateRepository shall expose the following method get_all_revoked_by(id) that returns all certificates that were issued by the given CA and are now revoked.
16 1 Jan Pašek
17 9 Jan Pašek
* Extensions of each certificate shall contain CRL and OCSP distribution points. Base URL of the server must be determined from the configuration
18
19 1 Jan Pašek
h3. Implement certificate deletion endpoint
20 5 Jan Pašek
21 9 Jan Pašek
* One Rest API endpoint: DELETE /api/certificates/{id} that deletes the certificate
22 8 Jan Pašek
* Controller calls CertificateService delete_certificate(id) that must be extended to delete the whole subtree of certificates
23
* To extend delete_certificate(id) a CertificateRepository must implement get_all_issued_by(id) that returns all certificates that were issued by the given CA
24 1 Jan Pašek
25 5 Jan Pašek
h3. Implement endpoint for retrieving public/private key for each certificate
26
27 9 Jan Pašek
* Two endpoints GET /api/certificates/{id}/publickey and GET /api/certificates/{id}/privatekey
28 8 Jan Pašek
* The first endpoint just queries the certificate using CertificateService, gets a private key ID, queries private key from the KeyService and returns its data.
29 1 Jan Pašek
* The second endpoint will do the same, except at the end it calls a new method of KeyService get_public_key(private_key) that utilizes OpenSSL via CryptographyService to get a public key out of the private key provided
30 8 Jan Pašek
31 5 Jan Pašek
h3. Implement endpoint for retrieving all certificates issued by a given CA
32 3 Jan Pašek
33 9 Jan Pašek
* Extend existing endpoint GET /api/certificates with another filtering option {issuedby: <id>}
34 8 Jan Pašek
* Controller can use new function of CertificateService get_certificates_issued_by(id) that calls CertificateRepository -> get_all_issued_by(id) (described previously)
35
36 3 Jan Pašek
h3. Implement creation OpenSSL index file
37 1 Jan Pašek
38 8 Jan Pašek
* Probably new service for CRL/OCSP
39 1 Jan Pašek
* One method create_revoked_index(ca_id) that queries revoked certificates of the given CA using get_all_revoked_by(id) of the CertificateRepository and creates index file based on the following link 
40
https://pki-tutorial.readthedocs.io/en/latest/cadb.html
41
42 9 Jan Pašek
h3. Implement CRL service and corresponding endpoint
43 8 Jan Pašek
44 9 Jan Pašek
* application endpoint that will use CRL/OCSP service to get CRL file that will be returned by the endpoint
45
* endpoint will be GET /api/crl/{ca_id}
46
* CRL/OCSP service must first generate the index file with revoked certificates and then call (maybe via cryptography service) OpenSSL to generate the CRL. Then the CRL file will be read in and returned 
47
48 1 Jan Pašek
h3. Implement OCSP service and corresponding endpoint
49
50 9 Jan Pašek
* application endpoint that reads the OSCP request from the request (in case of get -> URL parameter, in case of POST request body - see RFC for details)
51
* endpoint will be GET/POST /api/ocsp/{ca_id}
52
* OCSP request will  be passed to CRL/OCSP service
53
* CRL/OCSP service will generate the index file and calls (maybe via cryptography service) OpenSSL to generate OCSP response. The response is then returned to the controller.
54
* Both response and request are DER encoded data, so they are not readable...
55
* For signing OCSP additional certificate issued by the CA corresponding to the OCSP endpoint must be used. (this can be checked in RFC) 
56
57
58 1 Jan Pašek
h3. Logging
59
60 9 Jan Pašek
* Implement logging as specified in requirement specification NR 6 and start using it
61
* Shall not take too much time
62
* Simple rolling file
63
https://docs.python.org/3/library/logging.html
64
65 3 Jan Pašek
h3. Application initialization and DI
66 1 Jan Pašek
67 9 Jan Pašek
* Check if OpenSSL exists on the system
68
* DI: https://python-dependency-injector.ets-labs.org/index.html
69
70 1 Jan Pašek
h3. Database initialization
71 3 Jan Pašek
72 9 Jan Pašek
* Create a database file
73
* Create database tables
74
* Insert init data
75 1 Jan Pašek
76 9 Jan Pašek
77 1 Jan Pašek
h3. Certificate detailed view
78 9 Jan Pašek
79
* Display complete DN + notBefore + notAfter - via GET /api/certificates/{id}/details
80
* Reference to the detailed view page of the issuing CA - from the same data from the previous Rest call
81
* Display link to OCSP/CRL endpoint - only CA id in necessary to generate link - known from the previous Rest call
82
* Download public/private key - endpoints defined previously
83
* Download certificate, chain of trust, root - endpoints already available
84
* List of issued certificates using GET - /api/certificates with filtering option {issuedby: <id>}