From 9699f0710828a8a58200683368c7de51c2c94ddf Mon Sep 17 00:00:00 2001 From: Benson Kuang <3453547+bkuang@users.noreply.github.com> Date: Fri, 15 May 2020 15:47:27 -0400 Subject: [PATCH] Add main function to attestation verification script [(#3705)](https://github.com/GoogleCloudPlatform/python-docs-samples/issues/3705) * Add main function to attestation verification script. fixes #3704 * Add newline to end of file * remove a blank line at the end Co-authored-by: Benson Kuang Co-authored-by: Takashi Matsuo --- .../attestations/verify_attestation.py | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/packages/google-cloud-kms/samples/attestations/verify_attestation.py b/packages/google-cloud-kms/samples/attestations/verify_attestation.py index 69c16425f78c..e534ad9eecb4 100644 --- a/packages/google-cloud-kms/samples/attestations/verify_attestation.py +++ b/packages/google-cloud-kms/samples/attestations/verify_attestation.py @@ -14,13 +14,14 @@ # See the License for the specific language governing permissions and # limitations under the License. -"""This sample demonstrates how to verify HSM attestations using certificate -bundles obtained from Cloud HSM. +"""This application verifies HSM attestations using certificate bundles +obtained from Cloud HSM. For more information, visit https://cloud.google.com/kms/docs/attest-key. """ # [START verify_attestations] +import argparse import gzip from cryptography import exceptions @@ -69,3 +70,17 @@ def verify(attestation_file, bundle_file): continue return False # [END verify_attestations] + + +if __name__ == '__main__': + parser = argparse.ArgumentParser( + description=__doc__) + parser.add_argument('attestation_file', help="Name of attestation file.") + parser.add_argument('bundle_file', help="Name of certificate bundle file.") + + args = parser.parse_args() + + if verify(args.attestation_file, args.bundle_file): + print('Signature verified.') + else: + print('Signature verification failed.')