avbroot/openssl.py: Explicitly set -inform when querying RSA modulus

openssl 1.1 does not support autodetecting whether the input file is PEM
or DER encoded.

Issue: #2

Signed-off-by: Andrew Gunnerson <chillermillerlong@hotmail.com>
This commit is contained in:
Andrew Gunnerson
2022-10-24 10:33:43 -04:00
parent 1ce72c2513
commit ee297eb605
+5
View File
@@ -11,10 +11,15 @@ def _get_modulus(path, is_x509):
certificate.
'''
# openssl 1.1 does not support autodetection
with open(path, 'rb') as f:
is_pem = f.read(1) == b'-'
output = subprocess.check_output([
'openssl',
'x509' if is_x509 else 'rsa',
'-in', path,
'-inform', 'PEM' if is_pem else 'DER',
'-noout',
'-modulus',
])