Skip to content

Commit

Permalink
Revert "fix(dependency): update cryptography import (apache#22744)"
Browse files Browse the repository at this point in the history
This reverts commit e18bf3f.
  • Loading branch information
sadpandajoe committed Feb 3, 2023
1 parent b63ea63 commit 2a84049
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 9 deletions.
8 changes: 3 additions & 5 deletions requirements/base.txt
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ cron-descriptor==1.2.24
# via apache-superset
croniter==1.0.15
# via apache-superset
cryptography==39.0.0
cryptography==3.4.7
# via
# apache-superset
# paramiko
Expand Down Expand Up @@ -93,9 +93,7 @@ flask-compress==1.13
flask-jwt-extended==4.3.1
# via flask-appbuilder
flask-login==0.6.0
# via
# apache-superset
# flask-appbuilder
# via flask-appbuilder
flask-migrate==3.1.0
# via apache-superset
flask-sqlalchemy==2.5.1
Expand Down Expand Up @@ -152,6 +150,7 @@ markupsafe==2.1.1
# via
# jinja2
# mako
# werkzeug
# wtforms
marshmallow==3.13.0
# via
Expand Down Expand Up @@ -285,7 +284,6 @@ werkzeug==2.1.2
# via
# flask
# flask-jwt-extended
# flask-login
wtforms==2.3.3
# via
# apache-superset
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def get_git_sha() -> str:
"colorama",
"croniter>=0.3.28",
"cron-descriptor",
"cryptography>=39.0.0,<40",
"cryptography>=3.3.2",
"deprecation>=2.1.0, <2.2.0",
"flask>=2.1.3, <2.2",
"flask-appbuilder>=4.2.0, <5.0.0",
Expand Down
9 changes: 6 additions & 3 deletions superset/utils/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,9 @@
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.x509 import Certificate, load_pem_x509_certificate
from cryptography.hazmat.backends.openssl.x509 import _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 @@ -1534,7 +1535,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:
"""
Parses the contents of a certificate and returns a valid certificate object
if valid.
Expand All @@ -1544,7 +1545,9 @@ def parse_ssl_cert(certificate: str) -> Certificate:
:raises CertificateException: If certificate is not valid/unparseable
"""
try:
return load_pem_x509_certificate(certificate.encode("utf-8"), default_backend())
return x509.load_pem_x509_certificate(
certificate.encode("utf-8"), default_backend()
)
except ValueError as ex:
raise CertificateException("Invalid certificate") from ex

Expand Down
1 change: 1 addition & 0 deletions tests/integration_tests/utils_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -910,6 +910,7 @@ def test_merge_extra_filters_with_extras(self):
def test_ssl_certificate_parse(self):
parsed_certificate = parse_ssl_cert(ssl_certificate)
self.assertEqual(parsed_certificate.serial_number, 12355228710836649848)
self.assertRaises(CertificateException, parse_ssl_cert, "abc" + ssl_certificate)

def test_ssl_certificate_file_creation(self):
path = create_ssl_cert_file(ssl_certificate)
Expand Down

0 comments on commit 2a84049

Please sign in to comment.