mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Use to_str salt.utils when writing to a file.
This commit is contained in:
parent
dda1ebbabc
commit
651c5512d9
1 changed files with 5 additions and 6 deletions
|
@ -671,7 +671,7 @@ def read_crl(crl):
|
|||
text = get_pem_entry(text, pem_type='X509 CRL')
|
||||
|
||||
crltempfile = tempfile.NamedTemporaryFile()
|
||||
crltempfile.write(text)
|
||||
crltempfile.write(salt.utils.stringutils.to_str(text))
|
||||
crltempfile.flush()
|
||||
crlparsed = _parse_openssl_crl(crltempfile.name)
|
||||
crltempfile.close()
|
||||
|
@ -776,8 +776,7 @@ def write_pem(text, path, overwrite=True, pem_type=None):
|
|||
text = get_pem_entry(text, pem_type=pem_type)
|
||||
_dhparams = ''
|
||||
_private_key = ''
|
||||
if pem_type and pem_type == 'CERTIFICATE' and os.path.isfile(path) and \
|
||||
not overwrite:
|
||||
if pem_type and pem_type == 'CERTIFICATE' and os.path.isfile(path) and not overwrite:
|
||||
_filecontents = _text_or_file(path)
|
||||
try:
|
||||
_dhparams = get_pem_entry(_filecontents, 'DH PARAMETERS')
|
||||
|
@ -790,7 +789,7 @@ def write_pem(text, path, overwrite=True, pem_type=None):
|
|||
with salt.utils.files.fopen(path, 'w') as _fp:
|
||||
if pem_type and pem_type == 'CERTIFICATE' and _private_key:
|
||||
_fp.write(salt.utils.stringutils.to_str(_private_key))
|
||||
_fp.write(text)
|
||||
_fp.write(salt.utils.stringutils.to_str(text))
|
||||
if pem_type and pem_type == 'CERTIFICATE' and _dhparams:
|
||||
_fp.write(salt.utils.stringutils.to_str(_dhparams))
|
||||
return 'PEM written to {0}'.format(path)
|
||||
|
@ -1778,13 +1777,13 @@ def verify_crl(crl, cert):
|
|||
crltext = _text_or_file(crl)
|
||||
crltext = get_pem_entry(crltext, pem_type='X509 CRL')
|
||||
crltempfile = tempfile.NamedTemporaryFile()
|
||||
crltempfile.write(crltext)
|
||||
crltempfile.write(salt.utils.stringutils.to_str(crltext))
|
||||
crltempfile.flush()
|
||||
|
||||
certtext = _text_or_file(cert)
|
||||
certtext = get_pem_entry(certtext, pem_type='CERTIFICATE')
|
||||
certtempfile = tempfile.NamedTemporaryFile()
|
||||
certtempfile.write(certtext)
|
||||
certtempfile.write(salt.utils.stringutils.to_str(certtext))
|
||||
certtempfile.flush()
|
||||
|
||||
cmd = ('openssl crl -noout -in {0} -CAfile {1}'.format(
|
||||
|
|
Loading…
Add table
Reference in a new issue