mirror of
https://github.com/theupdateframework/python-tuf
synced 2026-05-24 10:08:28 +00:00
Do not store private key material in exception messages
This commit is contained in:
parent
2452076467
commit
d9ecbc851f
1 changed files with 16 additions and 4 deletions
20
tuf/keys.py
20
tuf/keys.py
|
|
@ -1135,16 +1135,28 @@ def extract_pem(pem, private_pem=False):
|
|||
header_start = pem.index(pem_header)
|
||||
|
||||
except ValueError:
|
||||
raise tuf.FormatError('Required PEM header ' + repr(pem_header) + '\n not'
|
||||
' found in PEM string: ' + repr(pem))
|
||||
# Be careful not to print private key material in exception message.
|
||||
if not private_pem:
|
||||
raise tuf.FormatError('Required PEM header ' + repr(pem_header) + '\n not'
|
||||
' found in PEM string: ' + repr(pem))
|
||||
|
||||
else:
|
||||
raise tuf.FormatError('Required PEM header ' + repr(pem_header) + '\n not'
|
||||
' found in private PEM string.')
|
||||
|
||||
try:
|
||||
# Search for 'pem_footer' after the PEM header.
|
||||
footer_start = pem.index(pem_footer, header_start + len(pem_header))
|
||||
|
||||
except ValueError:
|
||||
raise tuf.FormatError('Required PEM footer ' + repr(pem_footer) + '\n not'
|
||||
' found in PEM string ' + repr(pem))
|
||||
# Be careful not to print private key material in exception message.
|
||||
if not private_pem:
|
||||
raise tuf.FormatError('Required PEM footer ' + repr(pem_footer) + '\n not'
|
||||
' found in PEM string ' + repr(pem))
|
||||
|
||||
else:
|
||||
raise tuf.FormatError('Required PEM footer ' + repr(pem_footer) + '\n not'
|
||||
' found in private PEM string.')
|
||||
|
||||
# Extract only the public portion of 'pem'. Leading or trailing whitespace
|
||||
# is excluded.
|
||||
|
|
|
|||
Loading…
Reference in a new issue