|
1 | 1 | # Certificate Authority (CA)
|
2 | 2 |
|
3 |
| -## Link to the current specification |
4 |
| -Official |
5 |
| - |
6 |
| -Internal Preparation |
7 |
| -latest version in the slideset on the certificate policy presented in the working group meetings, can be found attached to the WG Certification meetings: https://industrialdataspace.jiveon.com/docs/DOC-3611 |
8 |
| - |
9 | 3 | ## Description
|
10 | 4 |
|
11 | 5 | This software is intended to be used as a mock CA for test environments. It does not offer any security guarantees and must not be used in productive environments.
|
12 | 6 |
|
| 7 | +Please, note that this document is only required for those end users who want to create and use different certificates for the deployment of IDS-testbed components. |
| 8 | + |
13 | 9 | ## Scope
|
14 | 10 |
|
15 |
| -This software simulates a PKI with root CAs, intermediate CAs and device certificates. Only PKIs with exactly one level of intermediate CAs are possible. |
| 11 | +This software simulates a PKI with root CAs, intermediate CAs and device certificates, including at the device certificates the AIA (Authority Information Access) extension information. |
16 | 12 |
|
17 |
| -The software supports secp256r1, secp384r1, secp521r1 as well as RSA with different key sizes. It also supports sha256, sha384 and sha512 as signing hashes. |
| 13 | +## Generate certificates |
18 | 14 |
|
19 |
| -## Dependencies |
| 15 | +At this step, all the neccessary certificates are generated for the use of IDS-testbed components. |
20 | 16 |
|
21 |
| -The software requires Python 3 and the Python OpenSSL library to be present. On Ubuntu this can be achieved by installing the package `python3-openssl`. |
| 17 | +``` |
| 18 | +./setup_PKI.sh {FOLDER_TO_BE_CREATED} |
| 19 | +``` |
22 | 20 |
|
23 |
| -## Installation |
| 21 | +It could look something like this: |
24 | 22 |
|
25 |
| -```bash |
26 |
| -$ git clone https://github.com/International-Data-Spaces-Association/IDS-testbed.git |
27 |
| -$ cd CertificateAuthority |
28 |
| -$ sudo apt install python3-openssl |
| 23 | +``` |
| 24 | +./setup_PKI.sh data-cfssl |
29 | 25 | ```
|
30 | 26 |
|
31 |
| -## Usage |
32 |
| - |
33 |
| -### Initialization |
| 27 | +### Revoke certificates |
34 | 28 |
|
35 |
| -Before any other operation is possible the necessary data directory must be initialized. This can be done with the following command: |
36 |
| -```bash |
37 |
| -python3 pki.py init |
38 |
| -``` |
39 |
| -**Caution:** This operation removes all created CAs, sub CAs and certificates. |
| 29 | +At this section, it is detailed the neccessary steps to manually revoke any of the previous step generated certificates. |
| 30 | +For the already existent folder "data-cfssl", the following certificate is revoked "connectorArevoked". |
40 | 31 |
|
41 |
| -### Creation of a Root CA |
| 32 | +The steps required to revoke a certificate are detailed at the following commands which need to be executed inside "data-cfssl" folder where the certificates are located. |
42 | 33 |
|
43 |
| -A root CA can then be created with the following command: |
44 |
| -```bash |
45 |
| -python3 pki.py ca create --common-name [CA name] --organization-name [O] --country-name [C] --unit-name [OU] --hash [Algorithm for signing] |
46 | 34 | ```
|
47 |
| -It could look something like this |
48 |
| -```bash |
49 |
| -python3 pki.py ca create --common-name ReferenceTestbedCA --organization-name SQS --country-name ES --unit-name TestLab --hash sha512 |
| 35 | +cd data-cfssl |
| 36 | +# Obtain certificate information to extract serial and AKI number identifiers. |
| 37 | +cfssl certinfo -cert certs/connectorArevoked.pem |
| 38 | +# Command to revoke the certificate |
| 39 | +# cfssl revoke -db-config ocsp/sqlite_db_components.json -serial {SERIAL_NUMBER} -aki {AKI_CERTIFICATE} -reason={REASON} |
| 40 | +# where AKI must be included as shown by certinfo without ":" and with all lowercase letters. |
| 41 | +# It could look something like this for the connectorArevoked certificate |
| 42 | +cfssl revoke -db-config ocsp/sqlite_db_components.json -serial "581921879588615033625472730240878974097738102962" -aki "c476d0aacd9379350feba7646090a46bb4384d33" -reason="superseded" |
50 | 43 | ```
|
51 |
| -A list of available parameters with their defaults can be obtained by: |
52 |
| -```bash |
53 |
| -python3 pki.py ca create -h |
| 44 | + |
| 45 | +### Refresh the OCSP server to include the changes |
| 46 | + |
| 47 | +Open a terminal at "data-cfssl" folder and execute the following commands: |
| 48 | + |
54 | 49 | ```
|
55 |
| -All root CAs created can be listed with the following command: |
56 |
| -```bash |
57 |
| -python3 pki.py ca list |
| 50 | +cfssl ocsprefresh -db-config ocsp/sqlite_db_components.json -ca subca/subca.pem -responder ocsp/ocsp_components.pem -responder-key ocsp/ocsp_components-key.pem |
| 51 | +
|
| 52 | +cfssl ocspdump -db-config ocsp/sqlite_db_components.json > ocsp/ocspdump_components.txt |
| 53 | +
|
| 54 | +cfssl ocspserve -port=8888 -responses=ocsp/ocspdump_components.txt -loglevel=0 |
58 | 55 | ```
|
59 | 56 |
|
60 |
| -### Creation of a Sub CA |
| 57 | +### Verify the changes against the OCSP server |
| 58 | + |
| 59 | +The following commands performs a check against the OCSP server to verify the revocation status of a certificate. |
61 | 60 |
|
62 |
| -A sub CA can then be created with the following command: |
63 |
| -```bash |
64 |
| -python3 pki.py subca create --CA [CA name] --common-name [Sub CA name] --organization-name [O] --country-name [C] --unit-name [OU] --hash [Algorithm for signing] |
65 | 61 | ```
|
66 |
| -It could look something like this |
67 |
| -```bash |
68 |
| -python3 pki.py subca create --CA "ReferenceTestbedCA" --common-name "ReferenceTestbedSubCA" --organization-name SQS --country-name ES --unit-name TestLab --hash sha384 |
| 62 | +openssl ocsp -issuer ocsp/ocsp_components.pem -issuer subca/subca.pem -no_nonce -cert certs/{CERTIFICATE}.pem -CAfile subca/subca.pem -text -url http://localhost:8888 |
69 | 63 | ```
|
70 |
| -The CA used for signing the sub CA is a required parameter. |
71 | 64 |
|
72 |
| -A list of available parameters with their defaults can be obtained by: |
73 |
| -```bash |
74 |
| -python3 pki.py subca create -h |
| 65 | +It could look something like this: |
| 66 | + |
75 | 67 | ```
|
76 |
| -All sub CAs created can be listed with the following command: |
77 |
| -```bash |
78 |
| -python3 pki.py subca list |
| 68 | +openssl ocsp -issuer ocsp/ocsp_components.pem -issuer subca/subca.pem -no_nonce -cert certs/connectorArevoked.pem -CAfile subca/subca.pem -text -url http://localhost:8888 |
79 | 69 | ```
|
80 | 70 |
|
81 |
| -### Creation of a Device Certificate |
| 71 | +### Extra commands for device certificates |
82 | 72 |
|
83 |
| -**Creation of key pair and certificate in one step** |
84 |
| -A device private key with the respective certificate can be created with the following command: |
85 |
| -```bash |
86 |
| -python3 pki.py cert create --subCA [Sub CA name] --common-name [Cert name] --algo [Key algorithm] --bits [Bits of Key] --hash [Algorithm for signing] --client --server --san-name [DNS Name] --san-ip [IP Address] |
87 |
| -``` |
| 73 | +At this section it is included the neccessary commands in order to obtain the certificates extensions required by IDS-testbed components for their implementation. |
88 | 74 |
|
89 |
| -Additionally, it can be included country name, organization name and unit name information. |
| 75 | +``` |
| 76 | +cd CertificateAuthority/data-cfssl/certs |
| 77 | +``` |
90 | 78 |
|
91 |
| -It could look something like this |
92 |
| -```bash |
93 |
| -python3 pki.py cert create --subCA ReferenceTestbedSubCA --common-name Example --algo rsa --bits 2048 --hash sha256 --country-name ES --organization-name SQS --unit-name TestLab --server --client --san-name ExampleDNS --san-ip 127.0.0.1 |
94 | 79 | ```
|
95 |
| -The Sub CA used for signing the certificate is a required parameter. The key algorithm `rsa`, bits of key `2048`, algorithm for signing `sha256` and Subject Alternative Name with DNS Name and IP Address are also required for correct interoperability between IDS-testbed components. |
| 80 | +openssl pkcs12 -export -out connectorA.p12 -in connectorA.pem -inkey connectorA-key.pem -passout pass:password |
| 81 | +openssl pkcs12 -in connectorA.p12 -clcerts -nokeys -out connectorA.crt -passin pass:password |
| 82 | +openssl pkcs12 -in connectorA.p12 -out connectorA.cert -nokeys -nodes -passin pass:password |
| 83 | +
|
| 84 | +openssl pkcs12 -export -out connectorB.p12 -in connectorB.pem -inkey connectorB-key.pem -passout pass:password |
| 85 | +openssl pkcs12 -in connectorB.p12 -clcerts -nokeys -out connectorB.crt -passin pass:password |
| 86 | +openssl pkcs12 -in connectorB.p12 -out connectorB.cert -nokeys -nodes -passin pass:password |
| 87 | +
|
| 88 | +openssl pkcs12 -export -out daps.p12 -in daps.pem -inkey daps-key.pem -passout pass:password |
| 89 | +openssl pkcs12 -in daps.p12 -clcerts -nokeys -out daps.crt -passin pass:password |
| 90 | +openssl pkcs12 -in daps.p12 -out daps.cert -nokeys -nodes -passin pass:password |
| 91 | +
|
| 92 | +openssl pkcs12 -export -out broker.p12 -in broker.pem -inkey broker-key.pem -passout pass:password |
| 93 | +openssl pkcs12 -in broker.p12 -clcerts -nokeys -out broker.crt -passin pass:password |
| 94 | +openssl pkcs12 -in broker.p12 -out broker.cert -nokeys -nodes -passin pass:password |
| 95 | +
|
| 96 | +openssl pkcs12 -export -out connectorArevoked.p12 -in connectorArevoked.pem -inkey connectorArevoked-key.pem -passout pass:password |
| 97 | +openssl pkcs12 -in connectorArevoked.p12 -clcerts -nokeys -out connectorArevoked.crt -passin pass:password |
| 98 | +openssl pkcs12 -in connectorArevoked.p12 -out connectorArevoked.cert -nokeys -nodes -passin pass:password |
| 99 | +
|
| 100 | +
|
| 101 | +cp connectorA-key.pem connectorA.key |
| 102 | +cp connectorB-key.pem connectorB.key |
| 103 | +cp daps-key.pem daps.key |
| 104 | +cp broker-key.pem broker.key |
| 105 | +cp connectorArevoked-key.pem connectorArevoked.key |
| 106 | +
|
| 107 | +chmod 664 broker.cert |
| 108 | +chmod 664 broker.p12 |
| 109 | +chmod 664 broker.crt |
| 110 | +chmod 664 broker.key |
| 111 | +chmod 664 daps.cert |
| 112 | +chmod 664 daps.crt |
| 113 | +chmod 664 daps.key |
| 114 | +chmod 664 daps.p12 |
| 115 | +chmod 664 connectorA.cert |
| 116 | +chmod 664 connectorA.crt |
| 117 | +chmod 664 connectorA.key |
| 118 | +chmod 664 connectorA.p12 |
| 119 | +chmod 664 connectorB.cert |
| 120 | +chmod 664 connectorB.crt |
| 121 | +chmod 664 connectorB.key |
| 122 | +chmod 664 connectorB.p12 |
| 123 | +chmod 664 connectorArevoked.cert |
| 124 | +chmod 664 connectorArevoked.crt |
| 125 | +chmod 664 connectorArevoked.key |
| 126 | +chmod 664 connectorArevoked.p12 |
| 127 | +``` |
96 | 128 |
|
97 |
| -The created key pair is located at the folder `CertificateAuthority/data/cert` |
| 129 | +### Extra commands for CA certificate |
98 | 130 |
|
99 |
| -**Creation of a certificate for an existing key pair** |
100 |
| -If a private-public key pair is already available on the device, the public key can be signed to gain a device certificate with the following command: |
101 |
| -```bash |
102 |
| -python3 pki.py cert sign --key-file [path to public key file] --subCA [Sub CA name] --common-name "Example" --client --server |
103 | 131 | ```
|
104 |
| -The path to the (public) key file and the Sub CA used for signing the certificate are required parameters. The public key file must be provided in PEM format. |
| 132 | +cd CertificateAuthority/data-cfssl/ca |
| 133 | +openssl pkcs12 -export -out ca.p12 -in ca.pem -inkey ca-key.pem -passout pass:password |
| 134 | +openssl pkcs12 -in ca.p12 -clcerts -nokeys -out ca.crt -passin pass:password |
| 135 | +openssl pkcs12 -in ca.p12 -out ca.cert -nokeys -nodes -passin pass:password |
| 136 | +cp ca-key.pem ca.key |
| 137 | +chmod 664 ca.cert |
| 138 | +chmod 664 ca.crt |
| 139 | +chmod 664 ca.key |
| 140 | +chmod 664 ca.p12 |
| 141 | +``` |
| 142 | + |
| 143 | +### Extra commands for subCA certificate |
105 | 144 |
|
106 |
| -A list of available parameters with their defaults can be obtained by: |
107 |
| -```bash |
108 |
| -python3 pki.py cert create -h |
109 | 145 | ```
|
110 |
| -All device certificates created can be listed with the following command: |
111 |
| -```bash |
112 |
| -python3 pki.py cert list |
| 146 | +cd CertificateAuthority/data-cfssl/subca |
| 147 | +openssl pkcs12 -export -out subca.p12 -in subca.pem -inkey subca-key.pem -passout pass:password |
| 148 | +openssl pkcs12 -in subca.p12 -clcerts -nokeys -out subca.crt -passin pass:password |
| 149 | +openssl pkcs12 -in subca.p12 -out subca.cert -nokeys -nodes -passin pass:password |
| 150 | +cp subca-key.pem subca.key |
| 151 | +chmod 664 subca.cert |
| 152 | +chmod 664 subca.crt |
| 153 | +chmod 664 subca.key |
| 154 | +chmod 664 subca.p12 |
113 | 155 | ```
|
0 commit comments