Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(dependency): update cryptography import #22744

Merged
merged 9 commits into from
Jan 31, 2023
Merged
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 3 additions & 6 deletions superset/utils/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,8 @@
import numpy as np
import pandas as pd
import sqlalchemy as sa
from cryptography import x509
from cryptography.hazmat.backends import default_backend
from cryptography.hazmat.backends.openssl.x509 import _Certificate
from cryptography.x509 import Certificate, load_pem_x509_certificate
from flask import current_app, flash, g, Markup, render_template, request
from flask_appbuilder import SQLA
from flask_appbuilder.security.sqla.models import Role, User
Expand Down Expand Up @@ -1550,7 +1549,7 @@ def override_user(user: Optional[User], force: bool = True) -> Iterator[Any]:
delattr(g, "user")


def parse_ssl_cert(certificate: str) -> _Certificate:
def parse_ssl_cert(certificate: str) -> Certificate:
Germandrummer92 marked this conversation as resolved.
Show resolved Hide resolved
"""
Parses the contents of a certificate and returns a valid certificate object
if valid.
Expand All @@ -1560,9 +1559,7 @@ def parse_ssl_cert(certificate: str) -> _Certificate:
:raises CertificateException: If certificate is not valid/unparseable
"""
try:
return x509.load_pem_x509_certificate(
certificate.encode("utf-8"), default_backend()
)
return load_pem_x509_certificate(certificate.encode("utf-8"), default_backend())
except ValueError as ex:
raise CertificateException("Invalid certificate") from ex

Expand Down