Skip to content

Commit 78ce383

Browse files
committed
Added index for certificates by subject
1 parent c2f831b commit 78ce383

File tree

74 files changed

+6046
-2176
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

74 files changed

+6046
-2176
lines changed

.github/workflows/verify.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ jobs:
125125
${{ runner.os }}-go-
126126
- name: Run integration tests
127127
shell: bash
128-
run: integration_tests/run-all.sh upgrade
128+
run: integration_tests/run-all.sh
129129
lint:
130130
if: needs.changes.outputs.go == 'true'
131131
name: Check linter issues with golangci-lint tool

README-DEV.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -125,15 +125,15 @@ Start a local pool as described above, and then just execute
125125
dcld
126126
```
127127

128-
Have a look at [How To](docs/how-to.md) and [transactions](docs/transactions/transactions.md) for instructions how to configure and use the CLI.
128+
Have a look at [How To](docs/how-to.md) and [transactions](docs/transactions.md) for instructions how to configure and use the CLI.
129129

130130
## REST
131131

132132
Start a local pool as described above.
133133

134134
Every node exposes a REST API at `http://<node-host>:1317` (see <https://docs.cosmos.network/v0.45/core/grpc_rest.html>).
135135

136-
Have a look at [transactions](docs/transactions/transactions.md) for a full list of REST endpoints.
136+
Have a look at [transactions](docs/transactions.md) for a full list of REST endpoints.
137137

138138
## Contributing
139139

README.md

+8-8
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ DC Ledger is based on [CometBFT](https://cometbft.com/) and [Cosmos SDK](https:/
2222

2323
DC Ledger is a public permissioned ledger in the following sense:
2424

25-
- Anyone can read from the ledger (that's why it's public). See [How to read from the Ledger](docs/transactions/transactions.md#how-to-read-from-the-ledger).
26-
- Writes to the ledger are permissioned. See [How to write to the Ledger](docs/transactions/transactions.md#how-to-write-to-the-ledger) for details.
25+
- Anyone can read from the ledger (that's why it's public). See [How to read from the Ledger](docs/transactions.md#how-to-read-from-the-ledger).
26+
- Writes to the ledger are permissioned. See [How to write to the Ledger](docs/transactions.md#how-to-write-to-the-ledger) for details.
2727
- PoA (proof of authority) approach is used for adding new validator nodes to the network
2828
(see [Add New Node Use Case](docs/use_cases/use_cases_add_validator_node.png)) and
2929
[Running Node](docs/running-node.md).
@@ -117,7 +117,7 @@ See [Run local pool](README-DEV.md#run-local-pool) section in [README-DEV.md](RE
117117
### CLI
118118

119119
- The same `dcld` binary as a Node
120-
- A full list of all CLI commands can be found there: [transactions.md](docs/transactions/transactions.md).
120+
- A full list of all CLI commands can be found there: [transactions.md](docs/transactions.md).
121121
- CLI can be used for write and read requests.
122122
- Please configure the CLI before using (see [how-to.md](docs/how-to.md#cli-configuration)).
123123
- **If there are no trusted Observer or Validator nodes to connect a CLI, then a [Light Client Proxy](#light-client-proxy) can be used.**
@@ -140,20 +140,20 @@ See [Run Light Client Proxy](docs/running-light-client-proxy.md) for details how
140140
- **There are no state proofs in REST, so REST queries should be sent to trusted Validator or Observer nodes only.**
141141
- OpenAPI specification: <https://zigbee-alliance.github.io/distributed-compliance-ledger/>.
142142
- Any running node exposes a REST API at port `1317`. See <https://docs.cosmos.network/v0.47/learn/advanced/grpc_rest>.
143-
- See [transactions](docs/transactions/transactions.md) for a full list of endpoints.
143+
- See [transactions](docs/transactions.md) for a full list of endpoints.
144144
- REST HTTP(S) queries can be directly used for read requests.
145-
See [How to read from the Ledger](docs/transactions/transactions.md#how-to-read-from-the-ledger).
145+
See [How to read from the Ledger](docs/transactions.md#how-to-read-from-the-ledger).
146146
- REST HTTP(S) queries can be directly used to broadcast generated and signed transaction.
147147
- Generation and signing of transactions need to be done in code or via CLI.
148-
See [How to write to the Ledger](docs/transactions/transactions.md#how-to-write-to-the-ledger).
148+
See [How to write to the Ledger](docs/transactions.md#how-to-write-to-the-ledger).
149149

150150
### gRPC
151151

152152
- **There are no state proofs in gRPC, so gRPC queries should be sent to trusted Validator or Observer nodes only.**
153153
- Any running node exposes a REST API at port `9090`. See <https://docs.cosmos.network/v0.47/learn/advanced/grpc_rest>.
154154
- A client code can be generated for all popular languages from the proto files [proto](proto), see <https://grpc.io/docs/languages/>.
155155
- The generated client code can be used for read and write requests, i.e. generation and signing of transactions
156-
See [How to read from the Ledger](docs/transactions/transactions.md#how-to-read-from-the-ledger) and [How to write to the Ledger](docs/transactions/transactions.md#how-to-write-to-the-ledger) for details.
156+
See [How to read from the Ledger](docs/transactions.md#how-to-read-from-the-ledger) and [How to write to the Ledger](docs/transactions.md#how-to-write-to-the-ledger) for details.
157157

158158
### CometBFT RPC and Light Client
159159

@@ -209,7 +209,7 @@ the following instructions from [how-to.md](docs/how-to.md) can be used for ever
209209

210210
- [OpenAPI specification](https://zigbee-alliance.github.io/distributed-compliance-ledger/)
211211
- [Quick Start](docs/quickStartGuide.adoc)
212-
- [List of Transactions, Queries, CLI command, REST API](docs/transactions/transactions.md)
212+
- [List of Transactions, Queries, CLI command, REST API](docs/transactions.md)
213213
- [How To Guide](docs/how-to.md)
214214
- [Use Case Diagrams](docs/use_cases)
215215
- [PKI](docs/use_cases/use_cases_pki.png)

docs/design/noc-root-cert-design.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ Retrieve NOC root certificates associated with a specific VID.
9696
- CLI Command:
9797
- `dcld query pki get_noc_x509_root_certs --vid=<uint16>`
9898
- REST API:
99-
- GET `/dcl/pki/noc-root-certificates/{vid}`
99+
- GET `/dcl/pki/noc-vid-root-certificates/{vid}`
100100

101101
### GET_ALL_NOC_X509_ROOT_CERTS
102102

docs/how-to.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ This document contains tutorials demonstrating how to accomplish common tasks us
66
- If write requests to the Ledger needs to be sent, please make sure that you have
77
an Account created on the Ledger with an appropriate role (see [Getting Account](#getting-account) section in [how-to.md](how-to.md)).
88
- Sending read requests to the Ledger doesn't require an Account (Ledger is public for reads).
9-
- A full list of all CLI commands with all parameters can be found there: [transactions](transactions/transactions.md).
9+
- A full list of all CLI commands with all parameters can be found there: [transactions](transactions.md).
1010
- After the CLI is configured and Account with an appropriate role is created,
1111
the following instructions can be used for every role (see [Use Case Diagrams](use_cases)):
1212
- [Trustee](#trustee-instructions)

docs/pool-upgrade-how-to.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ One of the trustees proposes the upgrade using the following steps:
6060
```
6161
Please note, that it must be called against the `dcld` binary, not the platform archive itself. So, for Ubuntu, either take a `dcld` binary from the root folder of the release, or extract it from ` dcld.ubuntu.tar.gz`.
6262

63-
2. Sends [`ProposeUpgrade`](transactions/transactions.md#propose_upgrade) transaction
63+
2. Sends [`ProposeUpgrade`](transactions.md#propose_upgrade) transaction
6464
with the name of the new upgrade handler, the chosen ledger height and the
6565
info containing URLs of the new application version binaries for supported
6666
platforms with the calculated checksums.
@@ -92,7 +92,7 @@ Each of them uses the following steps to accomplish this:
9292
```
9393
Please note, that it must be called against the `dcld` binary, not the platform archive itself. So, for Ubuntu, either take a `dcld` binary from the root folder of the release, or extract it from ` dcld.ubuntu.tar.gz`.
9494

95-
2. Sends [`ApproveUpgrade`](transactions/transactions.md#approve_upgrade) transaction
95+
2. Sends [`ApproveUpgrade`](transactions.md#approve_upgrade) transaction
9696
with the name of the proposed upgrade.
9797

9898
For example:

docs/pool-upgrade.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,10 @@ Any upgrade plan has the following fields:
2727
## Workflow
2828

2929
Initially an upgrade plan is proposed by one of trustees using
30-
[propose-upgrade](transactions/transactions.md#propose_upgrade) command. Then the proposed
30+
[propose-upgrade](transactions.md) command. Then the proposed
3131
upgrade plan has to be approved by the majority of trustees (2/3 including the
3232
trustee who has proposed it) using
33-
[approve-upgrade](transactions/transactions.md#approve_upgrade) command. When the necessary
33+
[approve-upgrade](transactions.md#approve_upgrade) command. When the necessary
3434
count of approvals is gathered, the upgrade plan turns into the approved state
3535
and is actually scheduled.
3636

@@ -81,5 +81,5 @@ checksum when the URL is provided in the specified format. If the downloaded
8181
file checksum does not equal to the checksum provided in the URL, `go-getter`
8282
reports that checksums did not match. To view `Info` field value of an upgrade
8383
plan, just execute an appropriate query command from `dclupgrade` or `upgrade`
84-
module. See [Upgrade CLI commands reference](transactions/transactions.md#upgrade) for
84+
module. See [Upgrade CLI commands reference](transactions.md#upgrade) for
8585
details.

docs/static/openapi.yml

+5-5
Original file line numberDiff line numberDiff line change
@@ -10209,7 +10209,7 @@ paths:
1020910209
type: string
1021010210
tags:
1021110211
- Query
10212-
/dcl/pki/noc-certificates/{subject}:
10212+
/dcl/pki/all-noc-certificates/{subject}:
1021310213
get:
1021410214
summary: Queries a NocCertificatesBySubject by index.
1021510215
operationId: NocCertificatesBySubject
@@ -10256,7 +10256,7 @@ paths:
1025610256
type: string
1025710257
tags:
1025810258
- Query
10259-
/dcl/pki/noc-certificates/{subject}/{subjectKeyId}:
10259+
/dcl/pki/all-noc-certificates/{subject}/{subjectKeyId}:
1026010260
get:
1026110261
summary: Queries a NocCertificates by index.
1026210262
operationId: NocCertificates
@@ -10384,7 +10384,7 @@ paths:
1038410384
type: string
1038510385
tags:
1038610386
- Query
10387-
/dcl/pki/noc-certificates/{vid}/{subjectKeyId}:
10387+
/dcl/pki/noc-vid-certificates/{vid}/{subjectKeyId}:
1038810388
get:
1038910389
summary: Queries a NocCertificatesByVidAndSkid by index.
1039010390
operationId: NocCertificatesByVidAndSkid
@@ -10716,7 +10716,7 @@ paths:
1071610716
type: boolean
1071710717
tags:
1071810718
- Query
10719-
/dcl/pki/noc-ica-certificates/{vid}:
10719+
/dcl/pki/noc-vid-ica-certificates/{vid}:
1072010720
get:
1072110721
summary: Queries a NocIcaCertificates by index.
1072210722
operationId: NocIcaCertificates
@@ -11039,7 +11039,7 @@ paths:
1103911039
type: boolean
1104011040
tags:
1104111041
- Query
11042-
/dcl/pki/noc-root-certificates/{vid}:
11042+
/dcl/pki/noc-vid-root-certificates/{vid}:
1104311043
get:
1104411044
summary: Queries a NocRootCertificates by index.
1104511045
operationId: NocRootCertificates

docs/transactions/transactions.md docs/transactions.md

+31-13
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ See use case sequence diagrams for the examples of how transaction can be used.
2121

2222
- Every writer to the Ledger must
2323
- Have a private/public key pair.
24-
- Have an Account created on the ledger via `ACCOUNT` transaction (see [Use Case Txn Auth](../use_cases/use_cases_txn_auth.puml)).
24+
- Have an Account created on the ledger via `ACCOUNT` transaction (see [Use Case Txn Auth](use_cases/use_cases_txn_auth.puml)).
2525
- The Account stores the public part of the key
2626
- The Account has an associated role. The role is used for authorization policies.
2727
- Sign every transaction by the private key.
@@ -38,9 +38,9 @@ an Account or sign the request.
3838

3939
- Local CLI
4040
- Configure the CLI before using.
41-
See `CLI Configuration` section in [how-to.md](../how-to.md#cli-configuration).
41+
See `CLI Configuration` section in [how-to.md](how-to.md#cli-configuration).
4242
- Generate and store a private key for the Account to be used for sending.
43-
See `Getting Account` section in [how-to.md](../how-to.md#getting-account).
43+
See `Getting Account` section in [how-to.md](how-to.md#getting-account).
4444
- Send transactions to the ledger from the Account (`--from`).
4545
- it will automatically build a request, sign it by the account's key, and broadcast to the ledger.
4646
- See `CLI` sub-sections for every write request (transaction).
@@ -54,9 +54,9 @@ an Account or sign the request.
5454
- Broadcast transaction by CLI 1: `dcld tx broadcast txn.json`
5555
- To get the actual result of transaction, `dcld query tx=txHash` call must be executed, where `txHash` is the hash of previously executed transaction.
5656
- gRPC:
57-
- Generate a client code from the proto files [proto](../../proto) for the client language (see <https://grpc.io/docs/languages/>)
57+
- Generate a client code from the proto files [proto](../proto) for the client language (see <https://grpc.io/docs/languages/>)
5858
- Build, sign, and broadcast the message (transaction).
59-
See [grpc/rest integration tests](../../integration_tests/grpc_rest) as an example.
59+
See [grpc/rest integration tests](../integration_tests/grpc_rest) as an example.
6060
- REST API
6161
- Build and sign a transaction by one of the following ways
6262
- In code via gRPC (see above)
@@ -81,25 +81,25 @@ Please make sure that TLS is enabled in gRPC, REST or Light Client Proxy for sec
8181

8282
- Local CLI
8383
- See `CLI` section for every read request.
84-
- If there are no trusted Observer or Validator nodes to connect a CLI, then a [Light Client Proxy](../running-light-client-proxy.md) can be used.
84+
- If there are no trusted Observer or Validator nodes to connect a CLI, then a [Light Client Proxy](running-light-client-proxy.md) can be used.
8585
- REST API
8686
- OpenAPI specification: <https://zigbee-alliance.github.io/distributed-compliance-ledger/>.
8787
- Any running node exposes a REST API at port `1317`. See <https://docs.cosmos.network/v0.45/core/grpc_rest.html>.
8888
- See `REST API` section for every read request.
89-
- See [grpc/rest integration tests](../../integration_tests/grpc_rest) as an example.
89+
- See [grpc/rest integration tests](../integration_tests/grpc_rest) as an example.
9090
- There are no state proofs in REST, so REST queries should be sent to trusted Validator or Observer nodes only.
9191
- gRPC
9292
- Any running node exposes a REST API at port `9090`. See <https://docs.cosmos.network/v0.45/core/grpc_rest.html>.
93-
- Generate a client code from the proto files [proto](../../proto) for the client language (see <https://grpc.io/docs/languages/>).
94-
- See [grpc/rest integration tests](../../integration_tests/grpc_rest) as an example.
93+
- Generate a client code from the proto files [proto](../proto) for the client language (see <https://grpc.io/docs/languages/>).
94+
- See [grpc/rest integration tests](../integration_tests/grpc_rest) as an example.
9595
- There are no state proofs in gRPC, so gRPC queries should be sent to trusted Validator or Observer nodes only.
9696
- Tendermint RPC
9797
- Tendermint RPC OpenAPI specification can be found in <https://zigbee-alliance.github.io/distributed-compliance-ledger/>.
9898
- Tendermint RPC is exposed by every running node at port `26657`. See <https://docs.cosmos.network/v0.45/core/grpc_rest.html#tendermint-rpc>.
9999
- Tendermint RPC supports state proofs. Tendermint's Light Client library can be used to verify the state proofs.
100100
So, if Light Client API is used, then it's possible to communicate with non-trusted nodes.
101101
- Please note, that multi-value queries don't have state proofs support and should be sent to trusted nodes only.
102-
- Refer to [this doc](../cometbft-rpc.md) to see how to [subscribe](../cometbft-rpc.md#subscribe) to a Tendermint WebSocket based events and/or [query](../cometbft-rpc.md#querying-application-components) an application components.
102+
- Refer to [this doc](cometbft-rpc.md) to see how to [subscribe](cometbft-rpc.md#subscribe) to a Tendermint WebSocket based events and/or [query](cometbft-rpc.md#querying-application-components) an application components.
103103

104104
`NotFound` (404 code) is returned if an entry is not found on the ledger.
105105

@@ -1650,7 +1650,7 @@ Use [GET_ALL_REVOKED_NOC_ROOT](#get_all_revoked_noc_root-rcacs) to get a list of
16501650
- CLI Command:
16511651
- `dcld query pki noc-x509-root-certs --vid=<uint16>`
16521652
- REST API:
1653-
- GET `/dcl/pki/noc-root-certificates/{vid}`
1653+
- GET `/dcl/pki/noc-vid-root-certificates/{vid}`
16541654

16551655
#### GET_NOC_BY_VID_AND_SKID (RCACs/ICACs)
16561656

@@ -1670,7 +1670,7 @@ Use [GET_ALL_REVOKED_NOC_ICA](#get_all_revoked_noc_ica-icacs) to get a list of a
16701670
- CLI Command:
16711671
- `dcld query pki noc-x509-certs --vid=<uint16> --subject-key-id=<hex string>`
16721672
- REST API:
1673-
- GET `/dcl/pki/noc-certificates/{vid}/{subject_key_id}`
1673+
- GET `/dcl/pki/noc-vid-certificates/{vid}/{subject_key_id}`
16741674

16751675
#### GET_NOC_ICA_BY_VID (ICACs)
16761676

@@ -1687,7 +1687,7 @@ Use [GET_ALL_REVOKED_CERT](#get_all_revoked_certs) to get a list of all revoked
16871687
- CLI Command:
16881688
- `dcld query pki noc-x509-ica-certs --vid=<uint16>`
16891689
- REST API:
1690-
- GET `/dcl/pki/noc-ica-certificates/{vid}`
1690+
- GET `/dcl/pki/noc-vid-ica-certificates/{vid}`
16911691

16921692
#### GET_NOC_CERTS_BY_SUBJECT
16931693

@@ -1858,6 +1858,24 @@ Should be sent to trusted nodes only.
18581858
- REST API:
18591859
- GET `/dcl/pki/all-certificates`
18601860

1861+
#### GET_CERTS_BY_SUBJECT
1862+
1863+
**Status: Implemented**
1864+
1865+
Gets all certificates associated with a subject. This query works for all types of certificates (PAA, PAI, RCAC, ICAC).
1866+
1867+
Revoked certificates are not returned.
1868+
Use [GET_ALL_REVOKED_DA_CERTS](#get_all_revoked_da_certs) to get a list of all revoked DA certificates.
1869+
Use [GET_ALL_REVOKED_NOC_ROOT_CERTS](#get_all_revoked_noc_root-rcacs) to get a list of all revoked Noc Root certificates.
1870+
Use [GET_ALL_REVOKED_NOC_ICA_CERTS](#get_all_revoked_noc_ica-icacs) to get a list of all revoked Noc ICA certificates.
1871+
1872+
- Parameters:
1873+
- subject: `string` - certificates's `Subject` is base64 encoded subject DER sequence bytes
1874+
- CLI command:
1875+
- `dcld query pki all-subject-certs --subject=<base64 string>`
1876+
- REST API:
1877+
- GET `/dcl/pki/all-certificates/{subject}`
1878+
18611879
#### GET_CHILD_CERTS
18621880

18631881
**Status: Implemented**

integration_tests/cli/pki-combine-certs.sh

+12
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,18 @@ response_does_not_contain "$result" "\"subjectKeyId\": \"$da_root_subject_key_id
283283

284284
test_divider
285285

286+
echo "Request DA certificates by subject using global command"
287+
result=$(dcld query pki all-subject-certs --subject=$da_root_subject)
288+
echo $result | jq
289+
check_response "$result" "\"$da_root_subject\""
290+
check_response "$result" "\"$da_root_subject_key_id\""
291+
292+
echo "Request NOC certificates by subject using global command"
293+
result=$(dcld query pki all-subject-certs --subject=$noc_root_subject)
294+
echo $result | jq
295+
check_response "$result" "\"$noc_root_subject\""
296+
check_response "$result" "\"$noc_root_subject_key_id\""
297+
286298
echo "Request all DA certificates by subject must be empty"
287299
result=$(dcld query pki all-subject-x509-certs --subject="$da_root_subject")
288300
echo $result | jq

integration_tests/grpc_rest/pki/noc_cert_helpers.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ func GetNocX509RootCerts(suite *utils.TestSuite, vendorID int32) (*pkitypes.NocR
190190
var res pkitypes.NocRootCertificates
191191
if suite.Rest {
192192
var resp pkitypes.QueryGetNocRootCertificatesResponse
193-
err := suite.QueryREST(fmt.Sprintf("/dcl/pki/noc-root-certificates/%v", vendorID), &resp)
193+
err := suite.QueryREST(fmt.Sprintf("/dcl/pki/noc-vid-root-certificates/%v", vendorID), &resp)
194194
if err != nil {
195195
return nil, err
196196
}
@@ -218,7 +218,7 @@ func GetNocX509CertsByVidAndSkid(suite *utils.TestSuite, vendorID int32, subject
218218
var res pkitypes.NocCertificatesByVidAndSkid
219219
if suite.Rest {
220220
var resp pkitypes.QueryGetNocCertificatesByVidAndSkidResponse
221-
err := suite.QueryREST(fmt.Sprintf("/dcl/pki/noc-certificates/%v/%s", vendorID, url.QueryEscape(subjectKeyID)), &resp)
221+
err := suite.QueryREST(fmt.Sprintf("/dcl/pki/noc-vid-certificates/%v/%s", vendorID, url.QueryEscape(subjectKeyID)), &resp)
222222
if err != nil {
223223
return nil, err
224224
}
@@ -246,7 +246,7 @@ func GetNocX509IcaCerts(suite *utils.TestSuite, vendorID int32) (*pkitypes.NocIc
246246
var res pkitypes.NocIcaCertificates
247247
if suite.Rest {
248248
var resp pkitypes.QueryGetNocIcaCertificatesResponse
249-
err := suite.QueryREST(fmt.Sprintf("/dcl/pki/noc-ica-certificates/%v", vendorID), &resp)
249+
err := suite.QueryREST(fmt.Sprintf("/dcl/pki/noc-vid-ica-certificates/%v", vendorID), &resp)
250250
if err != nil {
251251
return nil, err
252252
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
syntax = "proto3";
2+
package zigbeealliance.distributedcomplianceledger.pki;
3+
4+
option go_package = "github.com/zigbee-alliance/distributed-compliance-ledger/x/pki/types";
5+
6+
message AllCertificatesBySubject {
7+
string subject = 1;
8+
repeated string subjectKeyIds = 2;
9+
uint32 schemaVersion = 3;
10+
11+
}
12+

0 commit comments

Comments
 (0)