-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Changes to Fix Ledger APIs used to set Contract Enclave atttestation …
…policy Signed-off-by: Prakash Narayana Moorthy <[email protected]>
- Loading branch information
1 parent
0085dab
commit 68430c2
Showing
10 changed files
with
263 additions
and
135 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
90 changes: 0 additions & 90 deletions
90
ledgers/ccf/pdo/ledgers/ccf/scripts/register_enclave_attestation_verification_policy.py
This file was deleted.
Oops, something went wrong.
63 changes: 63 additions & 0 deletions
63
ledgers/ccf/pdo/ledgers/ccf/scripts/set_contract_enclave_check_attestation_flag.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
#!/usr/bin/env python | ||
|
||
# Copyright 2023 Intel Corporation | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
import argparse | ||
import http | ||
import sys | ||
|
||
from loguru import logger as LOG | ||
|
||
from pdo.ledgers.ccf.common import parse_common_arguments | ||
|
||
|
||
# ----------------------------------------------------------------- | ||
def set_contract_enclave_check_attestation_flag(client, options): | ||
|
||
params = {} | ||
params['check_attestation'] = options.check_attestation | ||
|
||
r = client.post("/app/set_contract_enclave_check_attestatation_flag", params) | ||
if r.status_code != http.HTTPStatus.OK.value: | ||
LOG.error('failed to set contract enclave check-attestation flag: {}, code: {}'.format( | ||
r.body, r.status_code)) | ||
sys.exit(-1) | ||
|
||
# ----------------------------------------------------------------- | ||
def Main() : | ||
|
||
(_, unprocessed_args, member_client) = parse_common_arguments( | ||
sys.argv[1:], 'Fetch the ledger authority key from a CCF server', True) | ||
|
||
# Parse the arguments that are unique to the script | ||
parser = argparse.ArgumentParser(description='Set contract enclave attestation check flag') | ||
parser.add_argument('--check-attestation', default=False, help="enable attestation verification", action='store_true') | ||
|
||
local_options = parser.parse_args(unprocessed_args) | ||
|
||
# ----------------------------------------------------------------- | ||
try : | ||
set_contract_enclave_check_attestation_flag(member_client, local_options) | ||
except Exception as e: | ||
while e.__context__ : e = e.__context__ | ||
LOG.error('failed to set contract enclave attestation check flag: {}', str(e)) | ||
sys.exit(-1) | ||
|
||
LOG.info('successfully set contract enclave check-attestation flag ') | ||
sys.exit(0) | ||
|
||
# ----------------------------------------------------------------- | ||
# ----------------------------------------------------------------- | ||
Main() |
73 changes: 73 additions & 0 deletions
73
ledgers/ccf/pdo/ledgers/ccf/scripts/set_contract_enclave_expected_sgx_measurements.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
#!/usr/bin/env python | ||
|
||
# Copyright 2023 Intel Corporation | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
import argparse | ||
import http | ||
import sys | ||
|
||
from loguru import logger as LOG | ||
|
||
from pdo.ledgers.ccf.common import parse_common_arguments | ||
|
||
|
||
# ----------------------------------------------------------------- | ||
def set_contract_enclave_expected_sgx_measurements(client, options): | ||
|
||
params = {} | ||
params['mrenclave'] = options.mrenclave | ||
params['basename'] = options.basename | ||
params['ias_public_key'] = options.ias_public_key | ||
|
||
r = client.post("/app/set_contract_enclave_expected_sgx_measurements", params) | ||
if r.status_code != http.HTTPStatus.OK.value: | ||
LOG.error('failed to set contract enclave expected sgx measurements: {}, code: {}'.format( | ||
r.body, r.status_code)) | ||
sys.exit(-1) | ||
|
||
# ----------------------------------------------------------------- | ||
def Main() : | ||
|
||
(_, unprocessed_args, member_client) = parse_common_arguments( | ||
sys.argv[1:], 'Fetch the ledger authority key from a CCF server', True) | ||
|
||
# Parse the arguments that are unique to the script | ||
|
||
parser = argparse.ArgumentParser(description='Fetch the ledger authority key from a CCF server') | ||
parser.add_argument('--mrenclave', help="Expected MRENCLAVE of pdo enclaves", type=str) | ||
parser.add_argument('--basename', help="PDO enclave basename", type=str) | ||
parser.add_argument('--ias-public-key', help="IAS public key derived from cert used to verify report signatures", type=str) | ||
|
||
local_options = parser.parse_args(unprocessed_args) | ||
|
||
if (not local_options.mrenclave) or (not local_options.basename) or (not local_options.ias_public_key): | ||
parser.print_help() | ||
sys.exit(-1) | ||
|
||
|
||
# ----------------------------------------------------------------- | ||
try : | ||
set_contract_enclave_expected_sgx_measurements(member_client, local_options) | ||
except Exception as e: | ||
while e.__context__ : e = e.__context__ | ||
LOG.error('failed to set contract enclave attestation check flag: {}', str(e)) | ||
sys.exit(-1) | ||
|
||
LOG.info('successfully set contract enclave expected sgx measurements') | ||
sys.exit(0) | ||
|
||
# ----------------------------------------------------------------- | ||
# ----------------------------------------------------------------- | ||
Main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.