tcas-cli

command module
v0.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 6, 2024 License: AGPL-3.0 Imports: 1 Imported by: 0

README

TCAS Client

1. policy manager

1.1 set policy
./tcasctl policy set -u <url> -n <name> -f <rego file path> -t <attestation-type>
  • -u: optional, tcas's api url, default is https://api.trustcluster.cc
  • -n: must, policy name
  • -f: must, the path of policy file in rego format
  • -t: optional, the attestation-type of policy, support trustnode or trustcluster, default is trustnode

successful response

set policy successful, policy id: cfaaab6d-7a25-436e-a8d9-6357a1e4cb33
1.2 get policy list
./tcasctl policy list -u <url> -t <attestation-type>
  • -u: optional, tcas's api url, default is https://api.trustcluster.cc
  • -t: optional, the attestation-type of policy, support trustnode or trustcluster, default is trustnode successful response:
{
    "policies": [
        {
            "no": 2,
            "policy_id": "9e434346-682d-4c13-917d-24883ce096d1",
            "policy_rego": "cGFja2FnZSB0cnVzdG5vZGUKCmltcG9ydCBmdXR1cmUua2V5d29yZHMuZXZlcnkKCmRlZmF1bHQgdHJ1c3Rfbm9kZSA6PSBmYWxzZQoKdHJ1c3Rfbm9kZSB7CglhbGxvd2VkX25vZGUoaW5wdXQudHJ1c3Rfbm9kZSkKfQoKYWxsb3dlZF9ub2RlKG5vZGUpIHsKCW5vZGUudGVlLnZpcnRjY2FfcmltID09ICJlYTIxY2NlMWJiODM2Y2E3OTc4NGFjMTFhMmZlMjg4YzY3MWU1ZjYyYzI4ODM3MThlZDhkYTU5OTQ3YWUyOGIxIgoJbm9kZS50ZWUudmlydGNjYV9yZW0wID0gIjM3YTRhMDRmZTRjYjIxYTgwYTgxNDE5ZWI0Zjc1OTJmNzI3MTA2OTcyN2ZiNWViODU5ZmQxYjUwMzE5YmZhZTQiCn0K",
            "policy_name": "test-vcca1",
            "attestation_type": "trust_node",
            "policy_hash": "822e3ca44a68bd28797d61d6428dff04691c1811093d3cd589febd2b00309842",
            "version": 1,
            "createTime": "2024-07-24T09:17:22.4220796Z",
            "updateTime": "2024-07-24T09:17:22.42208149Z"
        },
        {
            "no": 1,
            "policy_id": "4ed9690b-962f-4279-abdb-fdccecba6775",
            "policy_rego": "cGFja2FnZSB0cnVzdG5vZGUKCmltcG9ydCBmdXR1cmUua2V5d29yZHMuZXZlcnkKCmRlZmF1bHQgdHJ1c3Rfbm9kZSA6PSBmYWxzZQoKdHJ1c3Rfbm9kZSB7CglhbGxvd2VkX25vZGUoaW5wdXQudHJ1c3Rfbm9kZSkKfQoKYWxsb3dlZF9ub2RlKG5vZGUpIHsKCW5vZGUudGVlLnZpcnRjY2FfcmltID09ICJlYTIxY2NlMWJiODM2Y2E3OTc4NGFjMTFhMmZlMjg4YzY3MWU1ZjYyYzI4ODM3MThlZDhkYTU5OTQ3YWUyOGIxIgoJbm9kZS50ZWUudmlydGNjYV9yZW0wID0gIjM3YTRhMDRmZTRjYjIxYTgwYTgxNDE5ZWI0Zjc1OTJmNzI3MTA2OTcyN2ZiNWViODU5ZmQxYjUwMzE5YmZhZTQiCn0K",
            "policy_name": "test-vcca",
            "attestation_type": "trust_node",
            "policy_hash": "822e3ca44a68bd28797d61d6428dff04691c1811093d3cd589febd2b00309842",
            "version": 1,
            "createTime": "2024-07-24T09:17:11.51031935Z",
            "updateTime": "2024-07-24T09:17:11.5103208Z"
        }
    ]
}
1.3 get the detail of the policy (unsupported now)
./tcasctl policy detail -u <url> -i <policy_id>
  • -i: must the id of policy

successful response :

        {
            "no": 1,
            "policy_id": "4ed9690b-962f-4279-abdb-fdccecba6775",
            "policy_rego": "cGFja2FnZSB0cnVzdG5vZGUKCmltcG9ydCBmdXR1cmUua2V5d29yZHMuZXZlcnkKCmRlZmF1bHQgdHJ1c3Rfbm9kZSA6PSBmYWxzZQoKdHJ1c3Rfbm9kZSB7CglhbGxvd2VkX25vZGUoaW5wdXQudHJ1c3Rfbm9kZSkKfQoKYWxsb3dlZF9ub2RlKG5vZGUpIHsKCW5vZGUudGVlLnZpcnRjY2FfcmltID09ICJlYTIxY2NlMWJiODM2Y2E3OTc4NGFjMTFhMmZlMjg4YzY3MWU1ZjYyYzI4ODM3MThlZDhkYTU5OTQ3YWUyOGIxIgoJbm9kZS50ZWUudmlydGNjYV9yZW0wID0gIjM3YTRhMDRmZTRjYjIxYTgwYTgxNDE5ZWI0Zjc1OTJmNzI3MTA2OTcyN2ZiNWViODU5ZmQxYjUwMzE5YmZhZTQiCn0K",
            "policy_name": "test-vcca",
            "attestation_type": "trust_node",
            "policy_hash": "822e3ca44a68bd28797d61d6428dff04691c1811093d3cd589febd2b00309842",
            "version": 1,
            "createTime": "2024-07-24T09:17:11.51031935Z",
            "updateTime": "2024-07-24T09:17:11.5103208Z"
        }
1.4 delete policy
./tcasctl policy delete -u <url> -i <policy_id>
  • -i: must the id of policy

successful response:

delete policy successful, the policy id is <policy_id>

2. secret manager

2.1 set secret
./tcasctl secret set -u <url> -n <name> -f <secret file> 
  • -f: must, the path of secret file, only support json format.
  • -n: must, the unique name of the secret

successful response:

set secret successful, secret id: <secret_id>
2.2 update secret
./tcasctl secret update -u <url> -f <new secret file> -i <secret id> 
  • -f: must, the path of new secret file, only support json format.

  • -i: must, the id of the old secret

  • successful response:

update secret successful, secret id: <secret_id>
2.3 get the secret base info list
./tcasctl secret list -u <url> 

successful response:

{
      "secrets": [
        {
            "id": "0d6f1080-dcf4-4961-8def-9fb1f98d6174",
            "name": "test-vcca",
            "createTime": "2024-07-24T08:41:06.62906502Z",
            "updateTime": "2024-07-24T08:41:06.62906712Z"
        }
    ]
}
2.4 delete secret
./tcasctl secret detele -u <url> -i <secret_id>
  • -i: must, the id of the old secret

successful response:

delete secret successful, secret id: <secret_id>

3 Attest

3.1 get token
./tcasctl attest token -u <url>  -t <tee> -d <base64 encoded userdata> -p <policy ids> -v <trust-devices>
  • -t: must, the type of tee, now support csv or virtcca
  • -d: optional, the base64 encoded userdata
  • -p: optional, the ids of the policy needed matching
  • -v: optional, the trust devices

eg: ./tcasctl attest token -u http://127.0.0.1:8081 -t virtcca -d MTIzYWJj

successful response:

<token>
3.2 get secret
./tcasctl attest secret -u <url>  -t <tee> -d <base64 encoded userdata> -p <policy ids> -v <trust-devices> -s <secretid> -o <output dir> 
  • -t: must, the type of tee, now support csv or virtcca
  • -s: must,the secret ID that needs to be obtained
  • -d: optional, the base64 encoded userdata
  • -p: optional, the ids of the policy needed matching
  • -v: optional, the trust devices
  • -o:optional, the output dir of the secret,default is ./tcas-secret

successful response:

{"key":"123"}
3.3 get cert
./tcasctl attest cert -u <url> -t <tee> -p <policy ids> -v <trust-devices> -k <publickey file> -c <common_name> -e <expiration> -i <ipaddresses> -o <output dir> 
  • -t: must, the type of tee, now support csv or virtcca
  • -p: optional, the ids of the policy needed matching
  • -v: optional, the trust devices
  • -k: optional, the ecc256 of publickey in pem format, if not present, will generate key pair randomly
  • -c: must, the cert's common_name
  • -e: optional, the cert's expiration time, default: 10 years
  • -i: optional, the cert's IP addresses extensions
  • -o:optional, the output dir of the cert and keys, default: ./tcas-certs

successful response:

get cert successful, the <publickey.pem> <privatekey.pem> <serial_number_common_name.crt> save in <output dir>

4.verify

4.1 get root CA
./tcasctl ca -u <url> -o <path> 

-o: optional, the save path of the ca cert

4.2 verify token
./tcasclt verify token -t <token> -f <the path of the cert>
  • -t:must,tcas's token
  • -f:optionally, the path of the CA certificate. If not, it will be verified online

successful response

verify token successful, the detail info of the token is as follow:
<token claims>
4.3 verify cert
./tcasectl verfiy cert -u <url> -f <the path of the cert> -c <the path of the ca cert>

-f: must, the path of the cert to be verified

-c: optional, the path of the CA certificate file.If not, the CA certificate will be automatically obtained

successful response:

<the path of the cert> verify successful 

reference

Documentation

Overview

Copyright © 2024 NAME HERE <EMAIL ADDRESS>

Directories

Path Synopsis
cmd
* @Author: jffan * @Date: 2024-07-31 15:01:17 * @LastEditTime: 2024-08-05 09:44:23 * @LastEditors: jffan * @FilePath: \gitee-tcas\cmd\root.go * @Description:
* @Author: jffan * @Date: 2024-07-31 15:01:17 * @LastEditTime: 2024-08-05 09:44:23 * @LastEditors: jffan * @FilePath: \gitee-tcas\cmd\root.go * @Description:
attest
* @Author: jffan * @Date: 2024-08-15 09:16:45 * @LastEditTime: 2024-08-20 15:52:56 * @LastEditors: jffan * @FilePath: \gitee-tcas\cmd\attest\cert.go * @Description:
* @Author: jffan * @Date: 2024-08-15 09:16:45 * @LastEditTime: 2024-08-20 15:52:56 * @LastEditors: jffan * @FilePath: \gitee-tcas\cmd\attest\cert.go * @Description:
ca
- @Author: jffan - @Date: 2024-08-05 09:34:20 - @LastEditTime: 2024-08-14 16:39:35 - @LastEditors: jffan - @FilePath: \tcas-cli\cmd\ca\ca.go - @Description: Command to obtain a CA certificate
- @Author: jffan - @Date: 2024-08-05 09:34:20 - @LastEditTime: 2024-08-14 16:39:35 - @LastEditors: jffan - @FilePath: \tcas-cli\cmd\ca\ca.go - @Description: Command to obtain a CA certificate
policy
* @Author: jffan * @Date: 2024-07-31 14:46:14 * @LastEditTime: 2024-08-13 10:56:45 * @LastEditors: jffan * @FilePath: \gitee-tcas\cmd\policy\delete.go * @Description: delete policy
* @Author: jffan * @Date: 2024-07-31 14:46:14 * @LastEditTime: 2024-08-13 10:56:45 * @LastEditors: jffan * @FilePath: \gitee-tcas\cmd\policy\delete.go * @Description: delete policy
secret
* @Author: jffan * @Date: 2024-08-01 15:47:27 * @LastEditTime: 2024-08-14 14:36:14 * @LastEditors: jffan * @FilePath: \tcas-cli\cmd\secret\delete.go * @Description: delete secret
* @Author: jffan * @Date: 2024-08-01 15:47:27 * @LastEditTime: 2024-08-14 14:36:14 * @LastEditors: jffan * @FilePath: \tcas-cli\cmd\secret\delete.go * @Description: delete secret
verify
* @Author: jffan * @Date: 2024-08-14 09:33:52 * @LastEditTime: 2024-08-20 14:35:08 * @LastEditors: jffan * @FilePath: \gitee-tcas\cmd\verify\cert.go * @Description:
* @Author: jffan * @Date: 2024-08-14 09:33:52 * @LastEditTime: 2024-08-20 14:35:08 * @LastEditors: jffan * @FilePath: \gitee-tcas\cmd\verify\cert.go * @Description:
* @Author: fanjf * @Date: 2024-07-26 11:01:16 * @LastEditTime: 2024-08-14 14:31:05 * @LastEditors: jffan * @FilePath: \tcas-cli\constants\outputformat.go * @Description: Format the output constant
* @Author: fanjf * @Date: 2024-07-26 11:01:16 * @LastEditTime: 2024-08-14 14:31:05 * @LastEditors: jffan * @FilePath: \tcas-cli\constants\outputformat.go * @Description: Format the output constant
* @Author: jffan * @Date: 2024-07-31 15:01:17
* @Author: jffan * @Date: 2024-07-31 15:01:17
csv
utils
file
* @Author: jffan * @Date: 2024-07-30 14:23:59 * @LastEditTime: 2024-08-15 09:24:19 * @LastEditors: jffan * @FilePath: \gitee-tcas\utils\file\file.go * @Description:
* @Author: jffan * @Date: 2024-07-30 14:23:59 * @LastEditTime: 2024-08-15 09:24:19 * @LastEditors: jffan * @FilePath: \gitee-tcas\utils\file\file.go * @Description:
request
* @Author: jffan * @Date: 2024-07-29 14:56:25 * @LastEditTime: 2024-07-29 15:23:49 * @LastEditors: jffan * @FilePath: \tcas-cli\utils\request\request.go * @Description: Copyright © 2024 <jffan@nanhulab.ac.cn>
* @Author: jffan * @Date: 2024-07-29 14:56:25 * @LastEditTime: 2024-07-29 15:23:49 * @LastEditors: jffan * @FilePath: \tcas-cli\utils\request\request.go * @Description: Copyright © 2024 <jffan@nanhulab.ac.cn>
tools
* @Author: jffan * @Date: 2024-07-31 14:18:43 * @LastEditTime: 2024-07-31 14:42:15 * @LastEditors: jffan * @FilePath: \tcas-gitee\utils\tools\tools.go * @Description: Some utility functions
* @Author: jffan * @Date: 2024-07-31 14:18:43 * @LastEditTime: 2024-07-31 14:42:15 * @LastEditors: jffan * @FilePath: \tcas-gitee\utils\tools\tools.go * @Description: Some utility functions

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL