Skip to content

Commit

Permalink
Fix build error
Browse files Browse the repository at this point in the history
  • Loading branch information
jtschladen committed Jan 14, 2025
1 parent f65fcad commit 1ff3e71
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 12 deletions.
12 changes: 9 additions & 3 deletions lemur/common/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@
import string

import OpenSSL
import josepy as jose
import pem
import sqlalchemy
from certbot.crypto_util import CERT_PEM_REGEX
from cryptography import x509
from cryptography.exceptions import InvalidSignature, UnsupportedAlgorithm
from cryptography.hazmat.backends import default_backend
Expand All @@ -25,13 +27,11 @@
from cryptography.hazmat.primitives.serialization import load_pem_private_key, Encoding, pkcs7
from flask_restful.reqparse import RequestParser
from sqlalchemy import and_, func
import josepy as jose
from sqlalchemy.dialects.postgresql import TEXT

from certbot.crypto_util import CERT_PEM_REGEX
from lemur.constants import CERTIFICATE_KEY_TYPES
from lemur.exceptions import InvalidConfiguration
from lemur.utils import Vault
from sqlalchemy.dialects.postgresql import TEXT

paginated_parser = RequestParser()

Expand Down Expand Up @@ -525,3 +525,9 @@ def drop_last_cert_from_chain(full_chain: str) -> str:
),
).decode()
return pem_certificate


def csr_to_string(csr):
if isinstance(csr, str):
return csr.encode("ascii")
return csr
3 changes: 1 addition & 2 deletions lemur/plugins/lemur_acme/challenge_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,13 @@
from sentry_sdk import capture_exception

from lemur.authorizations import service as authorization_service
from lemur.common.utils import drop_last_cert_from_chain
from lemur.common.utils import drop_last_cert_from_chain, csr_to_string
from lemur.constants import ACME_ADDITIONAL_ATTEMPTS
from lemur.destinations import service as destination_service
from lemur.exceptions import LemurException, InvalidConfiguration
from lemur.extensions import metrics
from lemur.plugins.base import plugins
from lemur.plugins.lemur_acme.acme_handlers import AcmeHandler, AcmeDnsHandler
from lemur.plugins.lemur_acme.plugin import csr_to_string


class AcmeChallengeMissmatchError(LemurException):
Expand Down
8 changes: 1 addition & 7 deletions lemur/plugins/lemur_acme/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
from sentry_sdk import capture_exception

from lemur.authorizations import service as authorization_service
from lemur.common.utils import check_validation, drop_last_cert_from_chain
from lemur.common.utils import check_validation, drop_last_cert_from_chain, csr_to_string
from lemur.constants import CRLReason, EMAIL_RE
from lemur.dns_providers import service as dns_provider_service
from lemur.exceptions import InvalidConfiguration
Expand Down Expand Up @@ -466,9 +466,3 @@ def revoke_certificate(self, certificate, reason):
crl_reason = CRLReason[reason["crl_reason"]]

return self.acme.revoke_certificate(certificate, crl_reason.value)


def csr_to_string(csr):
if isinstance(csr, str):
return csr.encode("ascii")
return csr

0 comments on commit 1ff3e71

Please sign in to comment.