Fixed a problem where the OpenSSL bindings refuse to consume unicode

strings.
This commit is contained in:
J. Eduardo 2018-06-07 22:18:21 +02:00 committed by rallytime
parent 399cf08860
commit cc12844922
No known key found for this signature in database
GPG key ID: E8F1A4B90D0DEA19

View file

@ -25,6 +25,7 @@ import sys
# Import salt libs
import salt.utils.files
import salt.utils.path
import salt.utils.stringutils
import salt.exceptions
from salt.ext import six
from salt.utils.odict import OrderedDict
@ -945,6 +946,8 @@ def create_crl( # pylint: disable=too-many-arguments,too-many-locals
rev_item['not_after'] = rev_cert['Not After']
serial_number = rev_item['serial_number'].replace(':', '')
# OpenSSL bindings requires this to be a non-unicode string
serial_number = salt.utils.stringutils.to_str(serial_number)
if 'not_after' in rev_item and not include_expired:
not_after = datetime.datetime.strptime(
@ -961,11 +964,14 @@ def create_crl( # pylint: disable=too-many-arguments,too-many-locals
rev_date = rev_date.strftime('%Y%m%d%H%M%SZ')
rev = OpenSSL.crypto.Revoked()
rev.set_serial(serial_number)
rev.set_rev_date(rev_date)
if 'reason' in rev_item:
rev.set_reason(rev_item['reason'])
# Same here for OpenSSL bindings and non-unicode strings
reason = salt.utils.stringutils.to_str(rev_item['reason'])
rev.set_reason(reason)
crl.add_revoked(rev)