mirror of
https://github.com/certbot/certbot.git
synced 2026-07-28 08:45:22 +02:00
Bump Hardcoded RSA Default in API (#9855)
Rectifies: https://github.com/certbot/certbot/security/advisories/GHSA-pcq2-mjvr-m4jj
This commit is contained in:
@@ -168,7 +168,7 @@ class MakeKeyTest(unittest.TestCase):
|
||||
from certbot.crypto_util import make_key
|
||||
|
||||
# Do not test larger keys as it takes too long.
|
||||
OpenSSL.crypto.load_privatekey(OpenSSL.crypto.FILETYPE_PEM, make_key(1024))
|
||||
OpenSSL.crypto.load_privatekey(OpenSSL.crypto.FILETYPE_PEM, make_key(2048))
|
||||
|
||||
def test_ec(self): # pylint: disable=no-self-use
|
||||
# ECDSA Key Type Tests
|
||||
@@ -185,8 +185,8 @@ class MakeKeyTest(unittest.TestCase):
|
||||
from certbot.crypto_util import make_key
|
||||
|
||||
# Try a bad key size for RSA and ECDSA
|
||||
with pytest.raises(errors.Error, match='Unsupported RSA key length: 512'):
|
||||
make_key(bits=512, key_type='rsa')
|
||||
with pytest.raises(errors.Error, match='Unsupported RSA key length: 1024'):
|
||||
make_key(bits=1024, key_type='rsa')
|
||||
|
||||
def test_bad_elliptic_curve_name(self):
|
||||
from certbot.crypto_util import make_key
|
||||
@@ -200,7 +200,7 @@ class MakeKeyTest(unittest.TestCase):
|
||||
with pytest.raises(errors.Error,
|
||||
match=re.escape('Invalid key_type specified: unf. Use [rsa|ecdsa]')):
|
||||
OpenSSL.crypto.load_privatekey(
|
||||
OpenSSL.crypto.FILETYPE_PEM, make_key(1024, key_type='unf'))
|
||||
OpenSSL.crypto.FILETYPE_PEM, make_key(2048, key_type='unf'))
|
||||
|
||||
|
||||
class VerifyCertSetup(unittest.TestCase):
|
||||
|
||||
@@ -208,11 +208,11 @@ def import_csr_file(csrfile: str, data: bytes) -> Tuple[int, util.CSR, List[str]
|
||||
return PEM, util.CSR(file=csrfile, data=data_pem, form="pem"), domains
|
||||
|
||||
|
||||
def make_key(bits: int = 1024, key_type: str = "rsa",
|
||||
def make_key(bits: int = 2048, key_type: str = "rsa",
|
||||
elliptic_curve: Optional[str] = None) -> bytes:
|
||||
"""Generate PEM encoded RSA|EC key.
|
||||
|
||||
:param int bits: Number of bits if key_type=rsa. At least 1024 for RSA.
|
||||
:param int bits: Number of bits if key_type=rsa. At least 2048 for RSA.
|
||||
:param str key_type: The type of key to generate, but be rsa or ecdsa
|
||||
:param str elliptic_curve: The elliptic curve to use.
|
||||
|
||||
@@ -221,7 +221,7 @@ def make_key(bits: int = 1024, key_type: str = "rsa",
|
||||
:rtype: str
|
||||
"""
|
||||
if key_type == 'rsa':
|
||||
if bits < 1024:
|
||||
if bits < 2048:
|
||||
raise errors.Error("Unsupported RSA key length: {}".format(bits))
|
||||
|
||||
key = crypto.PKey()
|
||||
|
||||
Reference in New Issue
Block a user