From 578bd9702a25385323186888692ad27e7ba2e28a Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Fri, 24 Mar 2023 15:56:26 -0400 Subject: [PATCH] Sample script to install a cert into an XCC --- misc/installxcccert.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 misc/installxcccert.py diff --git a/misc/installxcccert.py b/misc/installxcccert.py new file mode 100644 index 00000000..c34f343b --- /dev/null +++ b/misc/installxcccert.py @@ -0,0 +1,22 @@ +import argparse +import pyghmi.redfish.command as cmd +import os +import sys + +ap = argparse.ArgumentParser(description='Certificate Generate') +ap.add_argument('xcc', help='XCC address') +ap.add_argument('cert', help='Certificate in PEM format') +args = ap.parse_args() + +c = cmd.Command(args.xcc, os.environ['XCCUSER'], os.environ['XCCPASS'], + verifycallback=lambda x: True) +wc = c.oem.wc +rawcert = open(args.cert, 'r').read() +cert = '' +incert = False +for line in rawcert.split('\n'): + if incert or '-----BEGIN CERTIFICATE-----' in line: + incert = True + cert += line + '\n' +res = wc.grab_json_response_with_status('/api/function', {'Sec_ImportCert': '0,1,0,0,,{0}'.format(cert)}) +print(repr(res))