Skip to content

Commit 1252be7

Browse files
authored
# 535 Enhancements to Adding, Revoking, and Removing Non-Root Certificates (#548)
* Allow add/remove/revoke cert operations for Vendor accounts with matching Subject/SKID * Update tests to handle the removal of non-root certificates * Fix validations for the 'Add X.509 Certificate' transaction * Change signer to Vendor for non-root certificate gRPC/REST tests * Update documentation for add/revoke/remove transactions
1 parent 252b7ee commit 1252be7

26 files changed

+2397
-1757
lines changed

docs/transactions.md

+12-11
Original file line numberDiff line numberDiff line change
@@ -905,13 +905,17 @@ already present on the ledger.
905905

906906
The certificate is immutable. It can only be revoked by either the owner or a quorum of Trustees.
907907

908+
- Who can send: Vendor account
909+
- PAA (Root certificates) are VID-scoped:
910+
- the vid field in the subject of the root certificate, as well as in the intermediate/leaf X509 certificates and the Vendor account's VID certificate, must be the same.
911+
- Non-VID scoped PAAs (Root certificates):
912+
- if the intermediate/leaf X509 certificate is VID-scoped, then the `vid` field in the certificate must match the corresponding PAA's `vid` field on the ledger, or the intermediate/leaf X509 certificate must not be VID-scoped.
913+
- `vid` field associated with the corresponding PAA on the ledger must be equal to the Vendor account's VID.
908914
- Parameters:
909915
- cert: `string` - PEM encoded certificate. The corresponding CLI parameter can contain either a PEM string or a path to a file containing the data.
910916
- In State:
911917
- `pki/ApprovedCertificates/value/<Certificate's Subject>/<Certificate's Subject Key ID>`
912918
- `pki/ChildCertificates/value/<Certificate's Subject>/<Certificate's Subject Key ID>`
913-
- Who can send:
914-
- Any role
915919
- CLI command:
916920
- `dcld tx pki add-x509-cert --certificate=<string-or-path> --from=<account>`
917921
- Validation:
@@ -921,7 +925,7 @@ The certificate is immutable. It can only be revoked by either the owner or a qu
921925
- no existing certificate with the same `<Certificate's Issuer>:<Certificate's Serial Number>` combination.
922926
- if certificates with the same `<Certificate's Subject>:<Certificate's Subject Key ID>` combination already exist:
923927
- the existing certificate must not be NOC certificate
924-
- sender must match to the owner of the existing certificates.
928+
- the sender's VID must match the `vid` field of the existing certificates.
925929
- the signature (self-signature) and expiration date are valid.
926930
- parent certificate must be already stored on the ledger and a valid chain to some root certificate can be built.
927931

@@ -938,9 +942,10 @@ If a Revocation Distribution Point needs to be published (such as RFC5280 Certif
938942

939943
If `revoke-child` flag is set to `true` then all the certificates in the chain signed by the revoked certificate will be revoked as well.
940944

941-
Only the owner (sender) can revoke the certificate.
942945
Root certificates can not be revoked this way, use `PROPOSE_X509_CERT_REVOC` and `APPROVE_X509_ROOT_CERT_REVOC` instead.
943946

947+
- Who can send: Vendor account
948+
- the sender's VID must match the `vid` field of the revoking certificates.
944949
- Parameters:
945950
- subject: `string` - certificates's `Subject` is base64 encoded subject DER sequence bytes
946951
- 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`
@@ -949,8 +954,6 @@ Root certificates can not be revoked this way, use `PROPOSE_X509_CERT_REVOC` an
949954
- info: `optional(string)` - information/notes for the revocation
950955
- time: `optional(int64)` - revocation time (number of nanoseconds elapsed since January 1, 1970 UTC). CLI uses the current time for that field.
951956
- In State: `pki/RevokedCertificates/value/<Certificate's Subject>/<Certificate's Subject Key ID>`
952-
- Who can send:
953-
- Any role; owner
954957
- CLI command:
955958
- `dcld tx pki revoke-x509-cert --subject=<base64 string> --subject-key-id=<hex string> --from=<account>`
956959

@@ -960,15 +963,14 @@ Root certificates can not be revoked this way, use `PROPOSE_X509_CERT_REVOC` an
960963

961964
Removes the given X509 certificate (either intermediate or leaf) from approved and revoked certificates list.
962965

963-
Only the owner (sender) can remove the certificate.
964966
Root certificates can not be removed this way.
965967

968+
- Who can send: Vendor account
969+
- the sender's VID must match the `vid` field of the removing certificates.
966970
- Parameters:
967971
- subject: `string` - certificates's `Subject` is base64 encoded subject DER sequence bytes
968972
- 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`
969973
- serial-number: `optional(string)` - certificate's serial number
970-
- Who can send:
971-
- Any role; owner
972974
- CLI command:
973975
- `dcld tx pki remove-x509-cert --subject=<base64 string> --subject-key-id=<hex string> --from=<account>`
974976

@@ -1041,7 +1043,6 @@ Publishing the revocation distribution endpoint doesn't automatically remove PAI
10411043
and DACs (leaf certificates) added to DCL if they are revoked in the CRL identified by this distribution point.
10421044
[REVOKE_X509_CERT](#revoke_x509_cert) needs to be called to remove an intermediate or leaf certificate from the ledger.
10431045

1044-
10451046
- Who can send: Vendor account
10461047
- `vid` field in the transaction (`VendorID`) must be equal to the Vendor account's VID
10471048
- VID-scoped PAAs (Root certs) and PAIs (Intermediate certs): `vid` field in the `CRLSignerCertificate`'s subject must be equal to the Vendor account's VID
@@ -1140,7 +1141,7 @@ This transaction adds a NOC root certificate owned by the Vendor.
11401141
- no existing certificate with the same `<Certificate's Issuer>:<Certificate's Serial Number>` combination.
11411142
- if certificates with the same `<Certificate's Subject>:<Certificate's Subject Key ID>` combination already exist:
11421143
- the existing certificate must be NOC root certificate
1143-
- the sender's VID must match the vid field of the existing certificates.
1144+
- the sender's VID must match the `vid` field of the existing certificates.
11441145
- the signature (self-signature) and expiration date must be valid.
11451146
- Parameters:
11461147
- cert: `string` - The NOC Root Certificate, encoded in X.509v3 PEM format. Can be a PEM string or a file path.

integration_tests/cli/pki-add-vendor-x509-certificates.sh

+78-8
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,15 @@ root_cert_with_vid_65521_subject="MIGYMQswCQYDVQQGEwJVUzERMA8GA1UECAwITmV3IFlvcm
55
root_cert_with_vid_65521_subject_key_id="CE:A8:92:66:EA:E0:80:BD:2B:B5:68:E4:0B:07:C4:FA:2C:34:6D:31"
66
root_cert_with_vid_65521_path="integration_tests/constants/root_cert_with_vid"
77
root_cert_with_vid_65521_vid=65521
8-
intermediate_cert_with_vid_subject="MIGuMQswCQYDVQQGEwJVUzERMA8GA1UECAwITmV3IFlvcmsxETAPBgNVBAcMCE5ldyBZb3JrMRgwFgYDVQQKDA9FeGFtcGxlIENvbXBhbnkxGTAXBgNVBAsMEFRlc3RpbmcgRGl2aXNpb24xGDAWBgNVBAMMD3d3dy5leGFtcGxlLmNvbTEUMBIGCisGAQQBgqJ8AgEMBEZGRjExFDASBgorBgEEAYKifAICDARGRkYx"
9-
intermediate_cert_with_vid_subject_key_id="0E:8C:E8:C8:B8:AA:50:BC:25:85:56:B9:B1:9C:C2:C7:D9:C5:2F:17"
8+
9+
intermediate_cert_with_vid_65521_subject="MIGuMQswCQYDVQQGEwJVUzERMA8GA1UECAwITmV3IFlvcmsxETAPBgNVBAcMCE5ldyBZb3JrMRgwFgYDVQQKDA9FeGFtcGxlIENvbXBhbnkxGTAXBgNVBAsMEFRlc3RpbmcgRGl2aXNpb24xGDAWBgNVBAMMD3d3dy5leGFtcGxlLmNvbTEUMBIGCisGAQQBgqJ8AgEMBEZGRjExFDASBgorBgEEAYKifAICDARGRkYx"
10+
intermediate_cert_with_vid_65521_subject_key_id="0E:8C:E8:C8:B8:AA:50:BC:25:85:56:B9:B1:9C:C2:C7:D9:C5:2F:17"
1011
intermediate_cert_with_vid_65521_path="integration_tests/constants/intermediate_cert_with_vid_1"
11-
intermediate_cert_with_vid_65522_path="integration_tests/constants/intermediate_cert_with_vid_2"
1212
intermediate_cert_with_vid_65521_serial_number="3"
13-
intermediate_cert_with_vid_65522_serial_number="4"
1413
intermediate_cert_with_vid_65521_vid=65521
14+
15+
intermediate_cert_with_vid_65522_path="integration_tests/constants/intermediate_cert_with_vid_2"
16+
intermediate_cert_with_vid_65522_serial_number="4"
1517
intermediate_cert_with_vid_65522_vid=65522
1618

1719
trustee_account="jack"
@@ -32,6 +34,10 @@ check_response "$result" "\"code\": 0"
3234
result=$(echo "$passphrase" | dcld tx pki approve-add-x509-root-cert --subject="$root_cert_with_vid_65521_subject" --subject-key-id="$root_cert_with_vid_65521_subject_key_id" --from $second_trustee_account --yes)
3335
check_response "$result" "\"code\": 0"
3436

37+
echo "Try to add the intermediate certificate using an account that does not have vendor role"
38+
result=$(echo "$passphrase" | dcld tx pki add-x509-cert --certificate="$intermediate_cert_with_vid_65521_path" --from $trustee_account --yes)
39+
check_response "$result" "\"code\": 4"
40+
3541
echo "Add an intermediate certificate with vid=$intermediate_cert_with_vid_65521_vid by $vendor_account_65521 with vid=$vendor_vid_65521"
3642
result=$(echo "$passphrase" | dcld tx pki add-x509-cert --certificate="$intermediate_cert_with_vid_65521_path" --from $vendor_account_65521 --yes)
3743
check_response "$result" "\"code\": 0"
@@ -41,8 +47,8 @@ result=$(dcld query pki all-x509-certs)
4147
echo $result | jq
4248
check_response "$result" "\"subject\": \"$root_cert_with_vid_65521_subject\""
4349
check_response "$result" "\"subjectKeyId\": \"$root_cert_with_vid_65521_subject_key_id\""
44-
check_response "$result" "\"subject\": \"$intermediate_cert_with_vid_subject\""
45-
check_response "$result" "\"subjectKeyId\": \"$intermediate_cert_with_vid_subject_key_id\""
50+
check_response "$result" "\"subject\": \"$intermediate_cert_with_vid_65521_subject\""
51+
check_response "$result" "\"subjectKeyId\": \"$intermediate_cert_with_vid_65521_subject_key_id\""
4652
check_response "$result" "\"serialNumber\": \"$intermediate_cert_with_vid_65521_serial_number\""
4753

4854
echo "Try to add an intermediate certificate with vid=$intermediate_cert_with_vid_65522_vid by $vendor_account_65521 with vid=$vendor_vid_65521"
@@ -53,15 +59,16 @@ echo "Request all approved root certificates should not contain intermediate cer
5359
result=$(dcld query pki all-x509-certs)
5460
echo $result | jq
5561
check_response "$result" "\"subject\": \"$root_cert_with_vid_65521_subject\""
56-
check_response "$result" "\"subject\": \"$intermediate_cert_with_vid_subject\""
62+
check_response "$result" "\"subject\": \"$intermediate_cert_with_vid_65521_subject\""
5763
check_response "$result" "\"subjectKeyId\": \"$root_cert_with_vid_65521_subject_key_id\""
58-
check_response "$result" "\"subjectKeyId\": \"$intermediate_cert_with_vid_subject_key_id\""
64+
check_response "$result" "\"subjectKeyId\": \"$intermediate_cert_with_vid_65521_subject_key_id\""
5965
check_response "$result" "\"serialNumber\": \"$intermediate_cert_with_vid_65521_serial_number\""
6066
response_does_not_contain "$result" "\"serialNumber\": \"$intermediate_cert_with_vid_65522_serial_number\""
6167

6268
root_cert_with_no_vid_path="integration_tests/constants/paa_cert_no_vid"
6369
root_cert_with_no_vid_subject="MBoxGDAWBgNVBAMMD01hdHRlciBUZXN0IFBBQQ=="
6470
root_cert_with_no_vid_subject_key_id="78:5C:E7:05:B8:6B:8F:4E:6F:C7:93:AA:60:CB:43:EA:69:68:82:D5"
71+
6572
intermediate_cert_with_vid_65522_path="integration_tests/constants/pai_cert_numeric_vid"
6673
intermediate_cert_with_vid_65522_subject="MDAxGDAWBgNVBAMMD01hdHRlciBUZXN0IFBBSTEUMBIGCisGAQQBgqJ8AgEMBEZGRjI="
6774
intermediate_cert_with_vid_65522_subject_key_id="61:3D:D0:87:35:5E:F0:8B:AE:01:E4:C6:9A:8F:C7:3D:AC:8C:7D:FD"
@@ -111,3 +118,66 @@ check_response "$result" "\"subjectKeyId\": \"$intermediate_cert_with_vid_65522_
111118
check_response "$result" "\"serialNumber\": \"$intermediate_cert_with_vid_65522_serial_number\""
112119

113120
test_divider
121+
122+
root_cert_subject="MIGCMQswCQYDVQQGEwJVUzERMA8GA1UECAwITmV3IFlvcmsxETAPBgNVBAcMCE5ldyBZb3JrMRgwFgYDVQQKDA9FeGFtcGxlIENvbXBhbnkxGTAXBgNVBAsMEFRlc3RpbmcgRGl2aXNpb24xGDAWBgNVBAMMD3d3dy5leGFtcGxlLmNvbQ=="
123+
root_cert_subject_key_id="33:5E:0C:07:44:F8:B5:9C:CD:55:01:9B:6D:71:23:83:6F:D0:D4:BE"
124+
root_cert_path="integration_tests/constants/root_with_same_subject_and_skid_1"
125+
root_cert_serial_number="1"
126+
127+
intermediate_cert_subject="MEUxCzAJBgNVBAYTAkFVMRMwEQYDVQQIDApTb21lLVN0YXRlMSEwHwYDVQQKDBhJbnRlcm5ldCBXaWRnaXRzIFB0eSBMdGQ="
128+
intermediate_cert_subject_key_id="2E:13:3B:44:52:2C:30:E9:EC:FB:45:FA:5D:E5:04:0A:C1:C6:E6:B9"
129+
intermediate_cert_1_path="integration_tests/constants/intermediate_with_same_subject_and_skid_1"
130+
intermediate_cert_1_serial_number="3"
131+
intermediate_cert_2_path="integration_tests/constants/intermediate_with_same_subject_and_skid_2"
132+
intermediate_cert_2_serial_number="4"
133+
134+
echo "Propose and approve root certificate"
135+
result=$(echo "$passphrase" | dcld tx pki propose-add-x509-root-cert --certificate="$root_cert_path" --vid "$vendor_vid_65521" --from $trustee_account --yes)
136+
check_response "$result" "\"code\": 0"
137+
result=$(echo "$passphrase" | dcld tx pki approve-add-x509-root-cert --subject="$root_cert_subject" --subject-key-id="$root_cert_subject_key_id" --from $second_trustee_account --yes)
138+
check_response "$result" "\"code\": 0"
139+
140+
echo "Add first intermediate certificate by $vendor_account_65521"
141+
result=$(echo "$passphrase" | dcld tx pki add-x509-cert --certificate="$intermediate_cert_1_path" --from $vendor_account_65521 --yes)
142+
check_response "$result" "\"code\": 0"
143+
144+
echo "Request all approved root certificates."
145+
result=$(dcld query pki all-x509-certs)
146+
echo $result | jq
147+
check_response "$result" "\"subject\": \"$root_cert_subject\""
148+
check_response "$result" "\"subjectKeyId\": \"$root_cert_subject_key_id\""
149+
check_response "$result" "\"subject\": \"$intermediate_cert_subject\""
150+
check_response "$result" "\"subjectKeyId\": \"$intermediate_cert_subject_key_id\""
151+
check_response "$result" "\"serialNumber\": \"$intermediate_cert_1_serial_number\""
152+
153+
echo "Try to add second intermediate certificate with same subject and SKID by $vendor_account_65523"
154+
result=$(echo "$passphrase" | dcld tx pki add-x509-cert --certificate="$intermediate_cert_2_path" --from $vendor_account_65523 --yes)
155+
check_response "$result" "\"code\": 4"
156+
157+
echo "Request all approved root certificates should not contain intermediate cert with serialNumber=$intermediate_cert_2_serial_number"
158+
result=$(dcld query pki all-x509-certs)
159+
echo $result | jq
160+
check_response "$result" "\"subject\": \"$root_cert_subject\""
161+
check_response "$result" "\"subjectKeyId\": \"$root_cert_subject_key_id\""
162+
check_response "$result" "\"subject\": \"$intermediate_cert_subject\""
163+
check_response "$result" "\"subjectKeyId\": \"$intermediate_cert_subject_key_id\""
164+
check_response "$result" "\"serialNumber\": \"$intermediate_cert_1_serial_number\""
165+
response_does_not_contain "$result" "\"serialNumber\": \"$intermediate_cert_2_serial_number\""
166+
167+
second_vendor_account_65521=second_vendor_account_$vendor_vid_65521
168+
echo "Create Vendor account - $second_vendor_account_65521"
169+
create_new_vendor_account $second_vendor_account_65521 $vendor_vid_65521
170+
171+
echo "Add second intermediate certificate with same subject and SKID by $second_vendor_account_65521"
172+
result=$(echo "$passphrase" | dcld tx pki add-x509-cert --certificate="$intermediate_cert_2_path" --from $vendor_account_65521 --yes)
173+
check_response "$result" "\"code\": 0"
174+
175+
echo "Request all approved root certificates should contain intermediate cert with serialNumber=$intermediate_cert_2_serial_number"
176+
result=$(dcld query pki all-x509-certs)
177+
echo $result | jq
178+
check_response "$result" "\"subject\": \"$root_cert_subject\""
179+
check_response "$result" "\"subjectKeyId\": \"$root_cert_subject_key_id\""
180+
check_response "$result" "\"subject\": \"$intermediate_cert_subject\""
181+
check_response "$result" "\"subjectKeyId\": \"$intermediate_cert_subject_key_id\""
182+
check_response "$result" "\"serialNumber\": \"$intermediate_cert_1_serial_number\""
183+
check_response "$result" "\"serialNumber\": \"$intermediate_cert_2_serial_number\""

integration_tests/cli/pki-demo.sh

+21-5
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,14 @@ trustee_account_address=$(echo $passphrase | dcld keys show jack -a)
4343
second_trustee_account_address=$(echo $passphrase | dcld keys show alice -a)
4444
third_trustee_account_address=$(echo $passphrase | dcld keys show bob -a)
4545

46+
vendor_account=vendor_account_$vid
47+
echo "Create Vendor account - $vendor_account"
48+
create_new_vendor_account $vendor_account $vid
49+
50+
vendor_account_65522=vendor_account_65522
51+
echo "Create Vendor account - $vendor_account_65522"
52+
create_new_vendor_account $vendor_account_65522 65522
53+
4654
echo "Create regular account"
4755
create_new_account user_account "CertificationCenter"
4856
test_divider
@@ -374,9 +382,9 @@ echo "4. ADD INTERMEDIATE CERT"
374382
test_divider
375383

376384

377-
echo "$user_account (Not Trustee) adds Intermediate certificate"
385+
echo "$vendor_account adds Intermediate certificate"
378386
intermediate_path="integration_tests/constants/intermediate_cert"
379-
result=$(echo "$passphrase" | dcld tx pki add-x509-cert --certificate="$intermediate_path" --from $user_account --yes)
387+
result=$(echo "$passphrase" | dcld tx pki add-x509-cert --certificate="$intermediate_path" --from $vendor_account --yes)
380388
check_response "$result" "\"code\": 0"
381389

382390

@@ -442,9 +450,9 @@ test_divider
442450
echo "5. ADD LEAF CERT"
443451
test_divider
444452

445-
echo "$trustee_account (Trustee) add Leaf certificate"
453+
echo "$vendor_account add Leaf certificate"
446454
leaf_path="integration_tests/constants/leaf_cert"
447-
result=$(echo "$passphrase" | dcld tx pki add-x509-cert --certificate="$leaf_path" --from $trustee_account --yes)
455+
result=$(echo "$passphrase" | dcld tx pki add-x509-cert --certificate="$leaf_path" --from $vendor_account --yes)
448456
check_response "$result" "\"code\": 0"
449457

450458
test_divider
@@ -650,8 +658,16 @@ test_divider
650658
echo "6. REVOKE INTERMEDIATE (AND HENCE LEAF) CERTS - No Approvals needed"
651659
test_divider
652660

653-
echo "$user_account (Not Trustee) revokes only Intermediate certificate. This must not revoke its child - Leaf certificate."
661+
echo "Try to revoke the intermediate certificate when sender is not Vendor account"
654662
result=$(echo "$passphrase" | dcld tx pki revoke-x509-cert --subject="$intermediate_cert_subject" --subject-key-id="$intermediate_cert_subject_key_id" --from=$user_account --yes)
663+
check_response "$result" "\"code\": 4"
664+
665+
echo "Try to revoke the intermediate certificate using a vendor account with other VID"
666+
result=$(echo "$passphrase" | dcld tx pki revoke-x509-cert --subject="$intermediate_cert_subject" --subject-key-id="$intermediate_cert_subject_key_id" --from=$vendor_account_65522 --yes)
667+
check_response "$result" "\"code\": 4"
668+
669+
echo "$vendor_account (Not Trustee) revokes only Intermediate certificate. This must not revoke its child - Leaf certificate."
670+
result=$(echo "$passphrase" | dcld tx pki revoke-x509-cert --subject="$intermediate_cert_subject" --subject-key-id="$intermediate_cert_subject_key_id" --from=$vendor_account --yes)
655671
check_response "$result" "\"code\": 0"
656672

657673
test_divider

0 commit comments

Comments
 (0)