Skip to content

Commit 9d759d0

Browse files
committed
Merge branch 'master' into feature/502-schema-compatibility
2 parents d78cfbf + 183290b commit 9d759d0

File tree

93 files changed

+8713
-517
lines changed

Some content is hidden

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

93 files changed

+8713
-517
lines changed

docs/static/openapi.yml

+554-5
Large diffs are not rendered by default.

docs/transactions.md

+78-1
Original file line numberDiff line numberDiff line change
@@ -843,6 +843,7 @@ The certificate is immutable. It can only be revoked by either the owner or a qu
843843
- no existing `Proposed` certificate with the same `<Certificate's Subject>:<Certificate's Subject Key ID>` combination.
844844
- no existing certificate with the same `<Certificate's Issuer>:<Certificate's Serial Number>` combination.
845845
- if approved certificates with the same `<Certificate's Subject>:<Certificate's Subject Key ID>` combination already exists:
846+
- the existing certificate must not be NOC certificate
846847
- sender must match to the owner of the existing certificates.
847848
- the signature (self-signature) and expiration date are valid.
848849

@@ -919,6 +920,7 @@ The certificate is immutable. It can only be revoked by either the owner or a qu
919920
- `Authority Key Identifier` != `Subject Key Identifier`
920921
- no existing certificate with the same `<Certificate's Issuer>:<Certificate's Serial Number>` combination.
921922
- if certificates with the same `<Certificate's Subject>:<Certificate's Subject Key ID>` combination already exist:
923+
- the existing certificate must not be NOC certificate
922924
- sender must match to the owner of the existing certificates.
923925
- the signature (self-signature) and expiration date are valid.
924926
- parent certificate must be already stored on the ledger and a valid chain to some root certificate can be built.
@@ -942,6 +944,7 @@ Root certificates can not be revoked this way, use `PROPOSE_X509_CERT_REVOC` an
942944
- Parameters:
943945
- subject: `string` - certificates's `Subject` is base64 encoded subject DER sequence bytes
944946
- subject_key_id: `string` - certificates's `Subject Key Id` in hex string format, e.g: `5A:88:0E:6C:36:53:D0:7F:B0:89:71:A3:F4:73:79:09:30:E6:2B:DB`
947+
- serial-number: `optional(string)` - certificate's serial number
945948
- info: `optional(string)` - information/notes for the revocation
946949
- time: `optional(int64)` - revocation time (number of nanoseconds elapsed since January 1, 1970 UTC). CLI uses the current time for that field.
947950
- In State: `pki/RevokedCertificates/value/<Certificate's Subject>/<Certificate's Subject Key ID>`
@@ -950,6 +953,24 @@ Root certificates can not be revoked this way, use `PROPOSE_X509_CERT_REVOC` an
950953
- CLI command:
951954
- `dcld tx pki revoke-x509-cert --subject=<base64 string> --subject-key-id=<hex string> --from=<account>`
952955

956+
### REMOVE_X509_CERT
957+
958+
**Status: Implemented**
959+
960+
Removes the given X509 certificate (either intermediate or leaf) from approved and revoked certificates list.
961+
962+
Only the owner (sender) can remove the certificate.
963+
Root certificates can not be removed this way.
964+
965+
- Parameters:
966+
- subject: `string` - certificates's `Subject` is base64 encoded subject DER sequence bytes
967+
- subject_key_id: `string` - certificates's `Subject Key Id` in hex string format, e.g: `5A:88:0E:6C:36:53:D0:7F:B0:89:71:A3:F4:73:79:09:30:E6:2B:DB`
968+
- serial-number: `optional(string)` - certificate's serial number
969+
- Who can send:
970+
- Any role; owner
971+
- CLI command:
972+
- `dcld tx pki remove-x509-cert --subject=<base64 string> --subject-key-id=<hex string> --from=<account>`
973+
953974
### PROPOSE_REVOKE_X509_ROOT_CERT
954975

955976
**Status: Implemented**
@@ -967,6 +988,7 @@ then the certificate will be in a pending state until sufficient number of other
967988
- Parameters:
968989
- subject: `string` - certificates's `Subject` is base64 encoded subject DER sequence bytes
969990
- subject_key_id: `string` - certificates's `Subject Key Id` in hex string format, e.g: `5A:88:0E:6C:36:53:D0:7F:B0:89:71:A3:F4:73:79:09:30:E6:2B:DB`
991+
- serial-number: `optional(string)` - certificate's serial number
970992
- info: `optional(string)` - information/notes for the revocation proposal
971993
- time: `optional(int64)` - revocation proposal time (number of nanoseconds elapsed since January 1, 1970 UTC). CLI uses the current time for that field.
972994
- In State: `pki/ProposedCertificateRevocation/value/<Certificate's Subject>/<Certificate's Subject Key ID>`
@@ -990,6 +1012,7 @@ The revocation is not applied until sufficient number of Trustees approve it.
9901012
- Parameters:
9911013
- subject: `string` - certificates's `Subject` is base64 encoded subject DER sequence bytes
9921014
- subject_key_id: `string` - certificates's `Subject Key Id` in hex string format, e.g: `5A:88:0E:6C:36:53:D0:7F:B0:89:71:A3:F4:73:79:09:30:E6:2B:DB`
1015+
- serial-number: `optional(string)` - certificate's serial number
9931016
- info: `optional(string)` - information/notes for the revocation approval
9941017
- time: `optional(int64)` - revocation approval time (number of nanoseconds elapsed since January 1, 1970 UTC). CLI uses the current time for that field.
9951018
- In State: `pki/RevokedCertificates/value/<Certificate's Subject>/<Certificate's Subject Key ID>`
@@ -1101,6 +1124,31 @@ Deletes a PKI Revocation distribution endpoint (such as RFC5280 Certificate Revo
11011124
- CLI command:
11021125
- `dcld tx pki delete-revocation-point --vid=<uint16> --issuer-subject-key-id=<string> --label=<string> --from=<account>`
11031126

1127+
### ADD_NOC_X509_ROOT_CERTIFICATE
1128+
1129+
**Status: Implemented**
1130+
1131+
This transaction adds a NOC root certificate owned by the Vendor.
1132+
1133+
- Who can send: Vendor account
1134+
- Validation:
1135+
- the provided certificate must be a root certificate:
1136+
- `Issuer` == `Subject`
1137+
- `Authority Key Identifier` == `Subject Key Identifier`
1138+
- no existing certificate with the same `<Certificate's Issuer>:<Certificate's Serial Number>` combination.
1139+
- if certificates with the same `<Certificate's Subject>:<Certificate's Subject Key ID>` combination already exist:
1140+
- the existing certificate must be NOC root certificate
1141+
- the sender's VID must match the vid field of the existing certificates.
1142+
- the signature (self-signature) and expiration date must be valid.
1143+
- Parameters:
1144+
- cert: `string` - The NOC Root Certificate, encoded in X.509v3 PEM format. Can be a PEM string or a file path.
1145+
- In State:
1146+
- `pki/ApprovedCertificates/value/<Subject>/<SubjectKeyID>`
1147+
- `pki/ApprovedCertificatesBySubject/value/<Subject>`
1148+
- `pki/ApprovedCertificatesBySubjectKeyID/value/<SubjectKeyID>`
1149+
- `pki/NOCRootCertificates/value/<VID>`
1150+
- CLI Command:
1151+
- `dcld tx pki add-noc-x509-root-cert --certificate=<string-or-path> --from=<account>`
11041152

11051153
### GET_X509_CERT
11061154

@@ -1222,10 +1270,11 @@ If a Revocation Distribution Point (such as RFC5280 Certificate Revocation List)
12221270
- Parameters:
12231271
- subject: `string` - certificates's `Subject` is base64 encoded subject DER sequence bytes
12241272
- subject_key_id: `string` - certificates's `Subject Key Id` in hex string format, e.g: `5A:88:0E:6C:36:53:D0:7F:B0:89:71:A3:F4:73:79:09:30:E6:2B:DB`
1273+
- serial-number: `optional(string)` - certificate's serial number
12251274
- CLI command:
12261275
- `dcld query pki proposed-x509-root-cert-to-revoke --subject=<base64 string> --subject-key-id=<hex string>`
12271276
- REST API:
1228-
- GET `/dcl/pki/proposed-revocation-certificates/{subject}/{subject_key_id}`
1277+
- GET `/dcl/pki/proposed-revocation-certificates/{subject}/{subject_key_id}?serialnumber={serialnumber}`
12291278

12301279
### GET_ALL_X509_ROOT_CERTS
12311280

@@ -1385,6 +1434,34 @@ Should be sent to trusted nodes only.
13851434
- REST API:
13861435
- GET `/dcl/pki/revocation-points`
13871436

1437+
### GET_NOC_X509_ROOT_CERTS_BY_VID
1438+
1439+
**Status: Implemented**
1440+
1441+
Retrieve NOC root certificates associated with a specific VID.
1442+
1443+
- Who can send: Any account
1444+
- Parameters:
1445+
- vid: `uint16` - Vendor ID (positive non-zero)
1446+
- CLI Command:
1447+
- `dcld query pki noc-x509-root-certs --vid=<uint16>`
1448+
- REST API:
1449+
- GET `/dcl/pki/noc-root-certificates/{vid}`
1450+
1451+
### GET_ALL_NOC_X509_ROOT_CERTS
1452+
1453+
**Status: Implemented**
1454+
1455+
Retrieve a list of all of NOC root certificates
1456+
1457+
- Who can send: Any account
1458+
- Parameters:
1459+
- Common pagination parameters
1460+
- CLI Command:
1461+
- `dcld query pki all-noc-x509-root-certs`
1462+
- REST API:
1463+
- GET `/dcl/pki/noc-root-certificates`
1464+
13881465
## AUTH
13891466

13901467
### PROPOSE_ADD_ACCOUNT

genlocalnetconfig.sh

+5
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,11 @@ for node_name in node0 node1 node2 node3 observer0; do
174174
# Make RPC endpoints available externally
175175
sed -i $SED_EXT 's/laddr = "tcp:\/\/127.0.0.1:26657"/laddr = "tcp:\/\/0.0.0.0:26657"/g' "$LOCALNET_DIR/${node_name}/config/config.toml"
176176

177+
# Make REST endpoints available externally
178+
sed -i $SED_EXT 's/address = "tcp:\/\/localhost:1317"/address = "tcp:\/\/0.0.0.0:1317"/g' "$LOCALNET_DIR/${node_name}/config/app.toml"
179+
# Make gRPC endpoints available externally
180+
sed -i $SED_EXT 's/address = "localhost:9090"/address = "0.0.0.0:9090"/g' "$LOCALNET_DIR/${node_name}/config/app.toml"
181+
177182
# sets proper moniker
178183
sed -i $SED_EXT "s/moniker = .*/moniker = \"$node_name\"/g" "$LOCALNET_DIR/${node_name}/config/config.toml"
179184

go.sum

+1-1
Original file line numberDiff line numberDiff line change
@@ -2764,4 +2764,4 @@ rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA=
27642764
sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o=
27652765
sigs.k8s.io/yaml v1.3.0 h1:a2VclLzOGrwOHDiV8EfBGhvjHvP46CtW5j6POvhYGGo=
27662766
sigs.k8s.io/yaml v1.3.0/go.mod h1:GeOyir5tyXNByN85N/dRIT9es5UQNerPYEKK56eTBm8=
2767-
sourcegraph.com/sourcegraph/appdash v0.0.0-20190731080439-ebfcffb1b5c0/go.mod h1:hI742Nqp5OhwiqlzhgfbWU4mW4yO10fP+LoT9WOswdU=
2767+
sourcegraph.com/sourcegraph/appdash v0.0.0-20190731080439-ebfcffb1b5c0/go.mod h1:hI742Nqp5OhwiqlzhgfbWU4mW4yO10fP+LoT9WOswdU=
+176
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,176 @@
1+
set -euo pipefail
2+
source integration_tests/cli/common.sh
3+
4+
noc_root_cert_1_path="integration_tests/constants/noc_root_cert_1"
5+
noc_root_cert_1_subject="MFUxCzAJBgNVBAYTAkFVMRMwEQYDVQQIDApTb21lLVN0YXRlMSEwHwYDVQQKDBhJbnRlcm5ldCBXaWRnaXRzIFB0eSBMdGQxDjAMBgNVBAMMBU5PQy0x"
6+
noc_root_cert_1_subject_key_id="44:EB:4C:62:6B:25:48:CD:A2:B3:1C:87:41:5A:08:E7:2B:B9:83:26"
7+
noc_root_cert_1_serial_number="217369606639495620450806539821422258966012867792"
8+
noc_root_cert_1_subject_as_text="CN=NOC-1,O=Internet Widgits Pty Ltd,ST=Some-State,C=AU"
9+
10+
noc_root_cert_2_path="integration_tests/constants/noc_root_cert_2"
11+
noc_root_cert_2_subject="MFUxCzAJBgNVBAYTAkFVMRMwEQYDVQQIDApTb21lLVN0YXRlMSEwHwYDVQQKDBhJbnRlcm5ldCBXaWRnaXRzIFB0eSBMdGQxDjAMBgNVBAMMBU5PQy0y"
12+
noc_root_cert_2_subject_key_id="CF:E6:DD:37:2B:4C:B2:B9:A9:F2:75:30:1C:AA:B1:37:1B:11:7F:1B"
13+
noc_root_cert_2_serial_number="720401643293243343104681760462974770802745092176"
14+
noc_root_cert_2_subject_as_text="CN=NOC-2,O=Internet Widgits Pty Ltd,ST=Some-State,C=AU"
15+
16+
noc_root_cert_3_path="integration_tests/constants/noc_root_cert_3"
17+
noc_root_cert_3_subject="MFUxCzAJBgNVBAYTAkFVMRMwEQYDVQQIDApTb21lLVN0YXRlMSEwHwYDVQQKDBhJbnRlcm5ldCBXaWRnaXRzIFB0eSBMdGQxDjAMBgNVBAMMBU5PQy0z"
18+
noc_root_cert_3_subject_key_id="88:0D:06:D9:64:22:29:34:78:7F:8C:3B:AE:F5:08:93:86:8F:0D:20"
19+
noc_root_cert_3_serial_number="38457288443253426021793906708335409501754677187"
20+
noc_root_cert_3_subject_as_text="CN=NOC-3,O=Internet Widgits Pty Ltd,ST=Some-State,C=AU"
21+
22+
trustee_account="jack"
23+
second_trustee_account="alice"
24+
25+
vid_in_hex_format=0x6006
26+
vid=24582
27+
28+
vendor_account=vendor_account_$vid_in_hex_format
29+
echo "Create Vendor account - $vendor_account"
30+
create_new_vendor_account $vendor_account $vid_in_hex_format
31+
32+
vid_2_in_hex_format=0x125D
33+
vid_2=4701
34+
35+
vendor_account_2=vendor_account_$vid_2_in_hex_format
36+
echo "Create Vendor account - $vendor_account_2"
37+
create_new_vendor_account $vendor_account_2 $vid_2_in_hex_format
38+
39+
40+
test_divider
41+
42+
echo "Request NOC certificate by VID must be empty"
43+
result=$(dcld query pki noc-x509-root-certs --vid="$vid")
44+
check_response "$result" "Not Found"
45+
response_does_not_contain "$result" "\"subject\": \"$noc_root_cert_1_subject\""
46+
response_does_not_contain "$result" "\"subjectKeyId\": \"$noc_root_cert_1_subject_key_id\""
47+
response_does_not_contain "$result" "\"serialNumber\": \"$noc_root_cert_1_serial_number\""
48+
response_does_not_contain "$result" "\"subjectAsText\": \"$noc_root_cert_1_subject_as_text\""
49+
echo $result | jq
50+
51+
test_divider
52+
53+
echo "Request all NOC root certificates must be empty"
54+
result=$(dcld query pki all-noc-x509-root-certs)
55+
check_response "$result" "\[\]"
56+
response_does_not_contain "$result" "\"subject\": \"$noc_root_cert_1_subject\""
57+
response_does_not_contain "$result" "\"subjectKeyId\": \"$noc_root_cert_1_subject_key_id\""
58+
response_does_not_contain "$result" "\"serialNumber\": \"$noc_root_cert_1_serial_number\""
59+
response_does_not_contain "$result" "\"subjectAsText\": \"$noc_root_cert_1_subject_as_text\""
60+
echo $result | jq
61+
62+
test_divider
63+
64+
echo "Request approved certificate must be empty"
65+
result=$(dcld query pki x509-cert --subject="$noc_root_cert_1_subject" --subject-key-id="$noc_root_cert_1_subject_key_id")
66+
check_response "$result" "Not Found"
67+
response_does_not_contain "$result" "\"subject\": \"$noc_root_cert_1_subject\""
68+
response_does_not_contain "$result" "\"subjectKeyId\": \"$noc_root_cert_1_subject_key_id\""
69+
response_does_not_contain "$result" "\"serialNumber\": \"$noc_root_cert_1_serial_number\""
70+
response_does_not_contain "$result" "\"subjectAsText\": \"$noc_root_cert_1_subject_as_text\""
71+
echo $result | jq
72+
73+
test_divider
74+
75+
echo "Request all certificates by subject must be empty"
76+
result=$(dcld query pki all-subject-x509-certs --subject="$noc_root_cert_1_subject")
77+
check_response "$result" "Not Found"
78+
response_does_not_contain "$result" "\"subject\": \"$noc_root_cert_1_subject\""
79+
response_does_not_contain "$result" "\"subjectKeyId\": \"$noc_root_cert_1_subject_key_id\""
80+
echo $result | jq
81+
82+
test_divider
83+
84+
echo "Request all certificates by subjectKeyId must be empty"
85+
result=$(dcld query pki x509-cert --subject-key-id="$noc_root_cert_1_subject_key_id")
86+
check_response "$result" "Not Found"
87+
response_does_not_contain "$result" "\"subject\": \"$noc_root_cert_1_subject\""
88+
response_does_not_contain "$result" "\"subjectKeyId\": \"$noc_root_cert_1_subject_key_id\""
89+
response_does_not_contain "$result" "\"serialNumber\": \"$noc_root_cert_1_serial_number\""
90+
response_does_not_contain "$result" "\"subjectAsText\": \"$noc_root_cert_1_subject_as_text\""
91+
echo $result | jq
92+
93+
test_divider
94+
95+
echo "Try to add inermidiate cert using add-noc-x509-root-cert command"
96+
intermediate_path="integration_tests/constants/intermediate_cert"
97+
result=$(echo "$passphrase" | dcld tx pki add-noc-x509-root-cert --certificate="$intermediate_path" --from $vendor_account --yes)
98+
check_response "$result" "\"code\": 414"
99+
100+
echo "Add first NOC root certificate by vendor with VID = $vid"
101+
result=$(echo "$passphrase" | dcld tx pki add-noc-x509-root-cert --certificate="$noc_root_cert_1_path" --from $vendor_account --yes)
102+
check_response "$result" "\"code\": 0"
103+
104+
echo "Add second NOC root certificate by vendor with VID = $vid"
105+
result=$(echo "$passphrase" | dcld tx pki add-noc-x509-root-cert --certificate="$noc_root_cert_2_path" --from $vendor_account --yes)
106+
check_response "$result" "\"code\": 0"
107+
108+
echo "Add third NOC root certificate by vendor with VID = $vid_2"
109+
result=$(echo "$passphrase" | dcld tx pki add-noc-x509-root-cert --certificate="$noc_root_cert_3_path" --from $vendor_account_2 --yes)
110+
check_response "$result" "\"code\": 0"
111+
112+
test_divider
113+
114+
echo "Request NOC root certificate by VID"
115+
result=$(dcld query pki noc-x509-root-certs --vid="$vid")
116+
echo $result | jq
117+
check_response "$result" "\"subject\": \"$noc_root_cert_1_subject\""
118+
check_response "$result" "\"subjectKeyId\": \"$noc_root_cert_1_subject_key_id\""
119+
check_response "$result" "\"serialNumber\": \"$noc_root_cert_1_serial_number\""
120+
check_response "$result" "\"subjectAsText\": \"$noc_root_cert_1_subject_as_text\""
121+
check_response "$result" "\"subject\": \"$noc_root_cert_2_subject\""
122+
check_response "$result" "\"subjectKeyId\": \"$noc_root_cert_2_subject_key_id\""
123+
check_response "$result" "\"serialNumber\": \"$noc_root_cert_2_serial_number\""
124+
check_response "$result" "\"subjectAsText\": \"$noc_root_cert_2_subject_as_text\""
125+
check_response "$result" "\"vid\": $vid"
126+
127+
test_divider
128+
129+
echo "Request All NOC root certificate"
130+
result=$(dcld query pki all-noc-x509-root-certs)
131+
echo $result | jq
132+
check_response "$result" "\"subject\": \"$noc_root_cert_1_subject\""
133+
check_response "$result" "\"subjectKeyId\": \"$noc_root_cert_1_subject_key_id\""
134+
check_response "$result" "\"serialNumber\": \"$noc_root_cert_1_serial_number\""
135+
check_response "$result" "\"subjectAsText\": \"$noc_root_cert_1_subject_as_text\""
136+
check_response "$result" "\"subject\": \"$noc_root_cert_2_subject\""
137+
check_response "$result" "\"subjectKeyId\": \"$noc_root_cert_2_subject_key_id\""
138+
check_response "$result" "\"serialNumber\": \"$noc_root_cert_2_serial_number\""
139+
check_response "$result" "\"subjectAsText\": \"$noc_root_cert_2_subject_as_text\""
140+
check_response "$result" "\"subject\": \"$noc_root_cert_3_subject\""
141+
check_response "$result" "\"subjectKeyId\": \"$noc_root_cert_3_subject_key_id\""
142+
check_response "$result" "\"serialNumber\": \"$noc_root_cert_3_serial_number\""
143+
check_response "$result" "\"subjectAsText\": \"$noc_root_cert_3_subject_as_text\""
144+
check_response "$result" "\"vid\": $vid"
145+
check_response "$result" "\"vid\": $vid_2"
146+
147+
test_divider
148+
149+
echo "Request NOC root certificate by Subject and SubjectKeyID"
150+
result=$(dcld query pki x509-cert --subject="$noc_root_cert_1_subject" --subject-key-id="$noc_root_cert_1_subject_key_id")
151+
echo $result | jq
152+
check_response "$result" "\"subject\": \"$noc_root_cert_1_subject\""
153+
check_response "$result" "\"subjectKeyId\": \"$noc_root_cert_1_subject_key_id\""
154+
check_response "$result" "\"serialNumber\": \"$noc_root_cert_1_serial_number\""
155+
check_response "$result" "\"subjectAsText\": \"$noc_root_cert_1_subject_as_text\""
156+
check_response "$result" "\"approvals\": \\[\\]"
157+
158+
test_divider
159+
160+
echo "Request NOC root certificate by Subject"
161+
result=$(dcld query pki all-subject-x509-certs --subject="$noc_root_cert_1_subject")
162+
echo $result | jq
163+
check_response "$result" "\"$noc_root_cert_1_subject\""
164+
check_response "$result" "\"$noc_root_cert_1_subject_key_id\""
165+
166+
test_divider
167+
168+
echo "Request NOC root certificate by SubjectKeyID"
169+
result=$(dcld query pki x509-cert --subject-key-id="$noc_root_cert_1_subject_key_id")
170+
echo $result | jq
171+
check_response "$result" "\"subject\": \"$noc_root_cert_1_subject\""
172+
check_response "$result" "\"subjectKeyId\": \"$noc_root_cert_1_subject_key_id\""
173+
check_response "$result" "\"serialNumber\": \"$noc_root_cert_1_serial_number\""
174+
check_response "$result" "\"subjectAsText\": \"$noc_root_cert_1_subject_as_text\""
175+
176+
test_divider

0 commit comments

Comments
 (0)