2020-08-07 23:35:11 +08:00
# Certs Service
2023-07-31 20:38:35 +08:00
MF-1179 - Add a certificate service and certs endpoint to SDK (#1188)
* adding certificate issuing
Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>
* adding cert endpoint
Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>
* update envs
Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>
* update envs
Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>
* move certs creation to sdk
Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>
* move certs creation to sdk
Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>
* move certs creation to sdk
Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>
* fix env vars
Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>
* add comment
Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>
* update sdk
Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>
* fix vars
Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>
* add volumes
Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>
* fix merge config for int
Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>
* remove env
Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>
* fix error handling
Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>
* add cert test, change receiver to pointer
Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>
* add docs
Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>
* fix var naming
Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>
* correct error naming
Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>
* adding certs service
Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>
* add certs
Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>
* add certs
Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>
* change func receiever
Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>
* add default cert issue method
Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>
* add config
Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>
* small fix
Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>
* remove some testing code
Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>
* add cert issue
Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>
* add vault api client
Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>
* additional endpoints
Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>
* add swagger for certs
Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>
* remove certs from provision
Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>
* clean provision from certs
Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>
* add list certificates endpoint
Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>
* add vault api in vendor
Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>
* add certs
Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>
* add revoke, fix bugs
Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>
* fix sdk for certs
Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>
* minor changes, add env, doc
Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>
* minor changes, add env, doc
Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>
* minor changes, add env, doc
Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>
* small changes
Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>
* remove CA for signing from provision
Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>
* add docker file for certs
Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>
* fix mock sdk
Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>
* add line
Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>
* fix RevokeCert
Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>
* renam ENV
Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>
* remove tests temporarily
Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>
* fix naming
Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>
* renam vars
Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>
* add cli for issue cert
Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>
* add cli for issue cert
Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>
* add cli for issue cert
Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>
* add cli for issue cert
Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>
* remove not needed envs
Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>
* fix linter errors, add cli
Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>
* fix linter errors, add cli, var rename
Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>
* fix reviews, add viewcert, fix view all certs
Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>
* remove view cert, as it will be retrieved from PKI
Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>
* change endpoints
Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>
* add default env val
Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>
* remove some errors
Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>
* refactor, make wrapper lib for vault
Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>
* refactor, make wrapper lib for vault
Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>
* refactor, make wrapper lib for vault
Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>
* fix revoking
Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>
* refactor, make wrapper lib for vault
Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>
* update vendor
Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>
* fix comment
Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>
* add comments
Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>
* remove unused
Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>
* remove unused field
Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>
* update vendor
Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>
* refactor pki
Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>
* refactor pki
Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>
* refactor pki, update vendor
Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>
* refactor pki
Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>
* fix comment
Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>
* minor fix
Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>
* remove methods, use fields
Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>
* fix comments and package desc
Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>
* fix comments and package desc
Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>
2020-07-21 18:53:21 +08:00
Issues certificates for things. `Certs` service can create certificates to be used when `Mainflux` is deployed to support mTLS.
2023-10-18 17:48:47 +08:00
Certificate service can create certificates using 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.
MF-1179 - Add a certificate service and certs endpoint to SDK (#1188)
* adding certificate issuing
Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>
* adding cert endpoint
Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>
* update envs
Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>
* update envs
Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>
* move certs creation to sdk
Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>
* move certs creation to sdk
Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>
* move certs creation to sdk
Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>
* fix env vars
Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>
* add comment
Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>
* update sdk
Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>
* fix vars
Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>
* add volumes
Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>
* fix merge config for int
Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>
* remove env
Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>
* fix error handling
Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>
* add cert test, change receiver to pointer
Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>
* add docs
Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>
* fix var naming
Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>
* correct error naming
Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>
* adding certs service
Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>
* add certs
Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>
* add certs
Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>
* change func receiever
Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>
* add default cert issue method
Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>
* add config
Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>
* small fix
Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>
* remove some testing code
Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>
* add cert issue
Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>
* add vault api client
Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>
* additional endpoints
Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>
* add swagger for certs
Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>
* remove certs from provision
Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>
* clean provision from certs
Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>
* add list certificates endpoint
Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>
* add vault api in vendor
Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>
* add certs
Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>
* add revoke, fix bugs
Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>
* fix sdk for certs
Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>
* minor changes, add env, doc
Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>
* minor changes, add env, doc
Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>
* minor changes, add env, doc
Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>
* small changes
Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>
* remove CA for signing from provision
Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>
* add docker file for certs
Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>
* fix mock sdk
Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>
* add line
Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>
* fix RevokeCert
Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>
* renam ENV
Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>
* remove tests temporarily
Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>
* fix naming
Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>
* renam vars
Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>
* add cli for issue cert
Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>
* add cli for issue cert
Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>
* add cli for issue cert
Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>
* add cli for issue cert
Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>
* remove not needed envs
Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>
* fix linter errors, add cli
Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>
* fix linter errors, add cli, var rename
Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>
* fix reviews, add viewcert, fix view all certs
Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>
* remove view cert, as it will be retrieved from PKI
Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>
* change endpoints
Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>
* add default env val
Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>
* remove some errors
Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>
* refactor, make wrapper lib for vault
Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>
* refactor, make wrapper lib for vault
Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>
* refactor, make wrapper lib for vault
Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>
* fix revoking
Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>
* refactor, make wrapper lib for vault
Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>
* update vendor
Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>
* fix comment
Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>
* add comments
Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>
* remove unused
Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>
* remove unused field
Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>
* update vendor
Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>
* refactor pki
Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>
* refactor pki
Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>
* refactor pki, update vendor
Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>
* refactor pki
Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>
* fix comment
Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>
* minor fix
Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>
* remove methods, use fields
Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>
* fix comments and package desc
Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>
* fix comments and package desc
Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>
2020-07-21 18:53:21 +08:00
2020-08-07 23:35:11 +08:00
## 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.
2022-01-05 02:42:13 +08:00
First you'll need to set up `Vault` .
2020-08-07 23:35:11 +08:00
To setup `Vault` follow steps in [Build Your Own Certificate Authority (CA) ](https://learn.hashicorp.com/tutorials/vault/pki-engine ).
To setup certs service with `Vault` following environment variables must be set:
2023-10-18 17:48:47 +08:00
```bash
2020-08-07 23:35:11 +08:00
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 >
```
For lab purposes you can use docker-compose and script for setting up PKI in [https://github.com/mteodor/vault ](https://github.com/mteodor/vault )
2023-10-18 17:48:47 +08:00
The certificates can also be revoked using `certs` service. To revoke a certificate you need to provide `thing_id` of the thing for which the certificate was issued.
2020-08-07 23:35:11 +08:00
```bash
2023-03-24 04:55:11 +08:00
curl -s -S -X DELETE http://localhost:9019/certs/revoke -H "Authorization: Bearer $TOK" -H 'Content-Type: application/json' -d '{"thing_id":"c30b8842-507c-4bcd-973c-74008cef3be5"}'
2021-03-02 19:20:52 +08:00
```