Skip to content

Commit

Permalink
tpm2_ptool: open pem w/o binary mode flag
Browse files Browse the repository at this point in the history
python2 and python3 differ in behavior on reading from a file that was
opened with the binary flag. In python2 the read data is a str, in
python3 its bytes. This is posing an issue in the asn1 calls as outlined
in bug:
  - etingof/pyasn1#185

We can work around this for now, since pem files are always string,
remove the binary flag.

Releates to bug tpm2-software#327

Signed-off-by: William Roberts <william.c.roberts@intel.com>
  • Loading branch information
William Roberts committed Nov 26, 2019
1 parent 0d92fce commit 1aea643
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion tools/tpm2_pkcs11/commandlets_keys.py
Original file line number Diff line number Diff line change
Expand Up @@ -523,7 +523,7 @@ def __call__(self, args):

# rather than use pycryptography x509 parser, which gives native type access to certficiate
# fields use pyASN1 to get raw ASN1 encoded values for the fields as the spec requires them
with open(certpath, "rb") as f:
with open(certpath, "r") as f:
substrate = pem.readPemFromFile(f)
cert = decoder.decode(substrate, asn1Spec=rfc2459.Certificate())[0]

Expand Down

0 comments on commit 1aea643

Please sign in to comment.