mirror of
https://github.com/mail-in-a-box/mailinabox.git
synced 2026-03-20 18:27:23 +01:00
Fixed EM101 (raw-string-in-exception): Exception must not use a string literal, assign to variable first
This commit is contained in:
committed by
Joshua Tauberer
parent
49124cc9ca
commit
dd61844ced
@@ -624,7 +624,8 @@ def load_cert_chain(pemfile):
|
||||
pem = f.read() + b"\n" # ensure trailing newline
|
||||
pemblocks = re.findall(re_pem, pem)
|
||||
if len(pemblocks) == 0:
|
||||
raise ValueError("File does not contain valid PEM data.")
|
||||
msg = "File does not contain valid PEM data."
|
||||
raise ValueError(msg)
|
||||
return pemblocks
|
||||
|
||||
def load_pem(pem):
|
||||
@@ -635,7 +636,8 @@ def load_pem(pem):
|
||||
from cryptography.hazmat.backends import default_backend
|
||||
pem_type = re.match(b"-+BEGIN (.*?)-+[\r\n]", pem)
|
||||
if pem_type is None:
|
||||
raise ValueError("File is not a valid PEM-formatted file.")
|
||||
msg = "File is not a valid PEM-formatted file."
|
||||
raise ValueError(msg)
|
||||
pem_type = pem_type.group(1)
|
||||
if pem_type in {b"RSA PRIVATE KEY", b"PRIVATE KEY"}:
|
||||
return serialization.load_pem_private_key(pem, password=None, backend=default_backend())
|
||||
|
||||
Reference in New Issue
Block a user