Switch the message digest name to bytes.
diff --git a/OpenSSL/crypto.py b/OpenSSL/crypto.py
index 4f0e7f2..ba83efe 100644
--- a/OpenSSL/crypto.py
+++ b/OpenSSL/crypto.py
@@ -1838,20 +1838,23 @@
export a CRL as a string
:param cert: Used to sign CRL.
+
:type cert: :class:`X509`
:param key: Used to sign CRL.
+
:type key: :class:`PKey`
- :param type: The export format, either :py:data:`FILETYPE_PEM`, :py:data:`FILETYPE_ASN1`, or :py:data:`FILETYPE_TEXT`.
-
+ :param type: The export format, either :py:data:`FILETYPE_PEM`,
+ :py:data:`FILETYPE_ASN1`, or :py:data:`FILETYPE_TEXT`.
:param days: The number of days until the next update of this CRL.
+
:type days: :py:data:`int`
- :param digest: The message digest to use (eg ``"sha1"``).
- :type digest: :py:data:`str`
+ :param bytes digest: The name of the message digest to use (eg
+ ``b"sha1"``).
- :return: :py:data:`str`
+ :return: :py:data:`bytes`
"""
if not isinstance(cert, X509):
raise TypeError("cert must be an X509 instance")
@@ -1867,9 +1870,9 @@
category=DeprecationWarning,
stacklevel=2,
)
- digest = "md5"
+ digest = b"md5"
- digest_obj = _lib.EVP_get_digestbyname(_byte_string(digest))
+ digest_obj = _lib.EVP_get_digestbyname(digest)
if digest_obj == _ffi.NULL:
raise ValueError("No such digest method")
diff --git a/OpenSSL/test/test_crypto.py b/OpenSSL/test/test_crypto.py
index b827281..7f70091 100644
--- a/OpenSSL/test/test_crypto.py
+++ b/OpenSSL/test/test_crypto.py
@@ -3073,11 +3073,25 @@
signature algorithm based on that digest function.
"""
crl = self._get_crl()
- dumped_crl = crl.export(self.cert, self.pkey, digest='sha1')
+ dumped_crl = crl.export(self.cert, self.pkey, digest=b"sha1")
text = _runopenssl(dumped_crl, b"crl", b"-noout", b"-text")
text.index(b('Signature Algorithm: sha1'))
+ def test_export_md5_digest(self):
+ """
+ If passed md5 as the digest function, ``CRL.export`` uses md5 and does
+ not emit a deprecation warning.
+ """
+ crl = self._get_crl()
+ with catch_warnings(record=True) as catcher:
+ simplefilter("always")
+ self.assertEqual(0, len(catcher))
+ dumped_crl = crl.export(self.cert, self.pkey, digest=b"md5")
+ text = _runopenssl(dumped_crl, b"crl", b"-noout", b"-text")
+ text.index(b('Signature Algorithm: md5'))
+
+
def test_export_default_digest(self):
"""
If not passed the name of a digest function, ``CRL.export`` uses a