-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
NOISSUE - Enhance Documentation For The Certs Service (#161)
* Enhance documentation for the certs service The documentation for the certs service had incorrect information about the different modes of operation. Specifically, the section about development mode was mistakenly labeled as PKI mode. This commit corrects the labeling and provides a more accurate description of PKI mode. The commit also includes additional information on setting up Vault for PKI mode and provides a link to the relevant documentation. Changes made: - Corrected labeling of the modes of operation in the certs service documentation - Added information on setting up Vault for PKI mode - Provided a link to the documentation for setting up Vault as a Certificate Authority (CA) Signed-off-by: Rodney Osodo <[email protected]> * Fix formatting and update instructions in certs.md Signed-off-by: Rodney Osodo <[email protected]> --------- Signed-off-by: Rodney Osodo <[email protected]>
- Loading branch information
1 parent
21368d6
commit f1f7afe
Showing
1 changed file
with
117 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,64 +7,151 @@ Provisioning is a process of configuration of an IoT platform in which system op | |
Issues certificates for things. `Certs` service can create certificates to be used when `Mainflux` is deployed to support mTLS. | ||
`Certs` service will create certificate for valid thing ID if valid user token is passed and user is owner of the provided thing ID. | ||
|
||
Certificate service can create certificates in two modes: | ||
Certificate service can create certificates in PKI mode - where certificates issued by PKI, when you deploy `Vault` as PKI certificate management `cert` service will proxy requests to `Vault` previously checking access rights and saving info on successfully created certificate. | ||
|
||
1. Development mode - to be used when no PKI is deployed, this works similar to the [make thing_cert](../docker/ssl/Makefile) | ||
2. PKI mode - certificates issued by PKI, when you deploy `Vault` as PKI certificate management `cert` service will proxy requests to `Vault` previously checking access rights and saving info on successfully created certificate. | ||
### PKI mode | ||
|
||
When `MF_CERTS_VAULT_HOST` is set, it is presumed that `Vault` is installed and `certs` service will issue certificates using `Vault` API. | ||
|
||
First you'll need to set up `Vault`. | ||
|
||
To setup `Vault` follow steps in [Build Your Own Certificate Authority (CA)][vault-pki-engine]. | ||
|
||
To setup certs service with `Vault` following environment variables must be set: | ||
|
||
```bash | ||
MF_CERTS_VAULT_HOST=vault-domain.com | ||
MF_CERTS_VAULT_PKI_PATH=<vault_pki_path> | ||
MF_CERTS_VAULT_ROLE=<vault_role> | ||
MF_CERTS_VAULT_TOKEN=<vault_acces_token> | ||
``` | ||
|
||
### Development mode | ||
For lab purposes you can use docker-compose and script for setting up PKI in [meodor-vault][meodor-vault]. | ||
|
||
If `MF_CERTS_VAULT_HOST` is empty than Development mode is on. | ||
Make sure you have an already running instance of `Mainflux` , `Vault` and `Certs` service. | ||
|
||
To issue a certificate: | ||
To start mainflux run: | ||
|
||
```bash | ||
make run up args="-d" | ||
``` | ||
|
||
USER_TOKEN=`curl -s --insecure -S -X POST https://localhost/users/tokens/issue -H "Content-Type: application/json" -d '{"identity":"[email protected]", "secret":"12345678"}' | grep -oP '"access_token":"\K[^"]+'` | ||
To start vault run: | ||
|
||
curl -s -S -X POST http://localhost:9019/certs -H "Authorization: Bearer $USER_TOKEN" -H 'Content-Type: application/json' -d '{"thing_id":<thing_id>, "rsa_bits":2048, "key_type":"rsa"}' | ||
```bash | ||
make run_addons vault up args="-d" | ||
``` | ||
|
||
```json | ||
When vault service is up and running some initializations steps must be done to setup things for `Certs` service. For more information about this steps please check [mainflux-vault][mainflux-vault] | ||
|
||
```bash | ||
bash docker/addons/vault/vault-init.sh | ||
bash docker/addons/vault/vault-unseal.sh | ||
bash docker/addons/vault/vault-set-pki.sh | ||
``` | ||
|
||
`vault-init.sh` initializes Vault, generates unseal keys and root tokens, and updates corresponding environment variables in the `.env` file. It's important to securely store these keys as they are required to unseal Vault. | ||
|
||
`vault-unseal.sh` is used to unseal Vault after initialization, but it's typically not needed since Vault can unseal itself when starting the container. | ||
|
||
`vault-set-pki.sh` generates certificates for Vault, including root and intermediate certificates, and copies them to the `docker/ssl/certs` folder. The CA parameters are sourced from environment variables in the `.env` file. | ||
|
||
To start certs service run: | ||
|
||
```bash | ||
make run_addons certs up args="-d" | ||
``` | ||
|
||
Provision a thing: | ||
|
||
```bash | ||
mainflux-cli provision test | ||
``` | ||
|
||
To stop certs service run: | ||
|
||
```bash | ||
make run_addons certs down | ||
``` | ||
|
||
To stop vault service run: | ||
|
||
```bash | ||
make run_addons vault down | ||
``` | ||
|
||
This step can be skipped if you already have a thing ID. | ||
|
||
#### 1. Issue a certificate | ||
|
||
```bash | ||
mainflux-cli certs issue <thing_id> <user_auth_token> [--ttl=8760h] | ||
``` | ||
|
||
For example: | ||
|
||
```bash | ||
mainflux-cli certs issue f13f0f30-f923-4504-8a7a-6aa45bcb4866 $USER_TOKEN | ||
|
||
{ | ||
"ThingID": "", | ||
"ClientCert": "-----BEGIN CERTIFICATE-----\nMIIDmTCCAoGgAwIBAgIRANmkAPbTR1UYeYO0Id/4+8gwDQYJKoZIhvcNAQELBQAw\nVzESMBAGA1UEAwwJbG9jYWxob3N0MREwDwYDVQQKDAhNYWluZmx1eDEMMAoGA1UE\nCwwDSW9UMSAwHgYJKoZIhvcNAQkBFhFpbmZvQG1haW5mbHV4LmNvbTAeFw0yMDA2\nMzAxNDIxMDlaFw0yMDA5MjMyMjIxMDlaMFUxETAPBgNVBAoTCE1haW5mbHV4MREw\nDwYDVQQLEwhtYWluZmx1eDEtMCsGA1UEAxMkYjAwZDBhNzktYjQ2YS00NTk3LTli\nNGYtMjhkZGJhNTBjYTYyMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA\ntgS2fLUWG3CCQz/l6VRQRJfRvWmdxK0mW6zIXGeeOILYZeaLiuiUnohwMJ4RiMqT\nuJbInAIuO/Tt5osfrCFFzPEOLYJ5nZBBaJfTIAxqf84Ou1oeMRll4wpzgeKx0rJO\nXMAARwn1bT9n3uky5QQGSLy4PyyILzSXH/1yCQQctdQB/Ar/UI1TaYoYlGzh7dHT\nWpcxq1HYgCyAtcrQrGD0rEwUn82UBCrnya+b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4aOWr9vJJ/siMm0rtKp4ijyBcevKBxHpeGWB\nWAR1FQKBgGIqAxGnBpip9E24gH894BaGHHMpQCwAxARev6sHKUy27eFUd6ipoTva\n4Wv36iz3gxU4R5B0gyfnxBNiUab/z90cb5+6+FYO13kqjxRRZWffohk5nHlmFN9K\nea7KQHTfTdRhOLUzW2yVqLi9pzfTfA6Yqf3U1YD3bgnWrp1VQnjo\n-----END RSA PRIVATE KEY-----\n", | ||
"PrivateKeyType": "", | ||
"Serial": "", | ||
"Expire": "0001-01-01T00:00:00Z" | ||
"cert_serial": "6f:35:d5:9d:47:9d:23:50:08:f7:31:13:82:22:e4:c8:e6:cf:2c:c1", | ||
"client_cert": "-----BEGIN CERTIFICATE-----\nMIIEATCCAumgAwIBAgIUbzXVnUedI1AI9zETgiLkyObPLMEwDQYJKoZIhvcNAQEL\nBQAwLjEsMCoGA1UEAxMjbWFpbmZsdXguY29tIEludGVybWVkaWF0ZSBBdXRob3Jp\ndHkwHhcNMjMwOTE0MTEwOTI5WhcNMjMxMDE0MTEwOTU4WjAvMS0wKwYDVQQDEyRi\nYTFmMmIxNi01MjA3LTQ2MDgtYTRkZS01ZmFiZmI4NjI3YzIwggEiMA0GCSqGSIb3\nDQEBAQUAA4IBDwAwggEKAoIBAQC9RxcHaTzn18vBdWWZf37K8Grc5dLW/m8vhwOJ\n8oe3iPUiE7xFijIXKw236R1NBh8fLT6/2lia/p4acZtls3yFRphooDwP7S2OiJRI\ngGb/r0SYmSnQKjHbdbixauNECGk1TDNSGvmpNSzvAZvYSJAvd5ZpYf/8Db9IBW0N\nvbI7TfIJHay8vC/0rn1BsmC3x+3nEm0W+Z5udC/UT4+pQn7QWrBsxjVT4r5WY0SQ\nkVhA9Wo+Wpzmy1CMC4X6yLmiIHmfRFlktDxKgPpyy/3zhAE2CkBpT7JEQ723Mv+m\n37oM2EJog+tgIZMExxDbw3Epqgo07B9DWpSZSBHCISeN/TzdAgMBAAGjggEUMIIB\nEDAOBgNVHQ8BAf8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frOasXiM9XbkzAjN9O0iV6+gfFSc\nFDHu1djnt565U7K2vxVLoTu/XsV1ajeQk5JsJRCK8cbgHsOxscP8XWobAJ/XrkhQ\nPoMOqwKBgD8goECBKj+SofUfqKCnGf3E2MWF3kTZMfPaBcuV8TaGMWRRljMmK8YT\npew6IIkAFrsIaXxQsym2JQ+j/L2AoxQkzlf2VF4SaBfUUByT3NijSBpD/d3xRlWA\n7UUO0d72YFnPTqY98Ch/fbKnaCRL/Usv8c9nCt5IdmnihYnuvxYT\n-----END RSA PRIVATE KEY-----", | ||
"expiration": "2023-10-14T11:09:58Z", | ||
"thing_id": "f13f0f30-f923-4504-8a7a-6aa45bcb4866" | ||
} | ||
``` | ||
|
||
### PKI mode | ||
|
||
When `MF_CERTS_VAULT_HOST` is set it is presumed that `Vault` is installed and `certs` service will issue certificates using `Vault` API. | ||
#### 2. Retrieve a certificate | ||
|
||
First you'll need to set up `Vault`. | ||
```bash | ||
mainflux-cli certs get [<cert_serial> | thing <thing_id>] <user_auth_token> | ||
``` | ||
|
||
To setup `Vault` follow steps in [Build Your Own Certificate Authority (CA)][vault-pki-engine]. | ||
For example: | ||
|
||
To setup certs service with `Vault` following environment variables must be set: | ||
```bash | ||
mainflux-cli certs get 6f:35:d5:9d:47:9d:23:50:08:f7:31:13:82:22:e4:c8:e6:cf:2c:c1 $USER_TOKEN | ||
{ | ||
"cert_serial": "6f:35:d5:9d:47:9d:23:50:08:f7:31:13:82:22:e4:c8:e6:cf:2c:c1", | ||
"client_cert": "-----BEGIN CERTIFICATE-----\nMIIEATCCAumgAwIBAgIUbzXVnUedI1AI9zETgiLkyObPLMEwDQYJKoZIhvcNAQEL\nBQAwLjEsMCoGA1UEAxMjbWFpbmZsdXguY29tIEludGVybWVkaWF0ZSBBdXRob3Jp\ndHkwHhcNMjMwOTE0MTEwOTI5WhcNMjMxMDE0MTEwOTU4WjAvMS0wKwYDVQQDEyRi\nYTFmMmIxNi01MjA3LTQ2MDgtYTRkZS01ZmFiZ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Kly/jhftEbKgGf2NR/d7\nEKVONjCEp6fL2iBaQSA/899oJJ7QPqE5X821HhBlXKvNmZnYRyUmAS2h1jnxtovp\nsNGcLFRgIAFdaGl1172C7mBZF4C3\n-----END CERTIFICATE-----", | ||
"expiration": "2023-10-14T11:09:58Z", | ||
"thing_id": "f13f0f30-f923-4504-8a7a-6aa45bcb4866" | ||
} | ||
``` | ||
|
||
```bash | ||
MF_CERTS_VAULT_HOST=vault-domain.com | ||
MF_CERTS_VAULT_PKI_PATH=<vault_pki_path> | ||
MF_CERTS_VAULT_ROLE=<vault_role> | ||
MF_CERTS_VAULT_TOKEN=<vault_acces_token> | ||
mainflux-cli certs get thing f13f0f30-f923-4504-8a7a-6aa45bcb4866 $USER_TOKEN | ||
{ | ||
"certs": [ | ||
{ | ||
"cert_serial": "6f:35:d5:9d:47:9d:23:50:08:f7:31:13:82:22:e4:c8:e6:cf:2c:c1", | ||
"expiration": "0001-01-01T00:00:00Z" | ||
} | ||
], | ||
"limit": 10, | ||
"offset": 0, | ||
"total": 1 | ||
} | ||
``` | ||
|
||
For lab purposes you can use docker-compose and script for setting up PKI in [https://github.com/mteodor/vault][meodor-vault]. | ||
#### 3. Revoke a certificate | ||
|
||
Issuing certificate is same as in **Development** mode. In this mode certificates can also be revoked: | ||
```bash | ||
mainflux-cli certs revoke <thing_id> <user_auth_token> | ||
``` | ||
|
||
For example: | ||
|
||
```bash | ||
curl -s -S -X DELETE http://localhost:9019/certs/revoke -H "Authorization: Bearer $TOKEN" -H 'Content-Type: application/json' -d '{"thing_id":"c30b8842-507c-4bcd-973c-74008cef3be5"}' | ||
mainflux-cli certs revoke f13f0f30-f923-4504-8a7a-6aa45bcb4866 $USER_TOKEN | ||
|
||
revoked: 2023-09-14 11:21:44 +0000 UTC | ||
``` | ||
|
||
For more information about the Certification service API, please check out the [API documentation][api-docs]. | ||
|
||
[vault-pki-engine]: https://learn.hashicorp.com/tutorials/vault/pki-engine | ||
[meodor-vault]: https://github.com/mteodor/vault | ||
[api-docs]: https://github.com/mainflux/mainflux/blob/master/api/certs.yml | ||
[mainflux-vault]: https://github.com/mainflux/mainflux/blob/master/docker/addons/vault/README.md#setup |