Skip to content

Commit

Permalink
Replace pyOpenSSL by cryptography
Browse files Browse the repository at this point in the history
The crypto module of the pyOpenSSL library is now discouraged and
the cryptography library should be used to manage certificates and
keys[1].

[1] https://www.pyopenssl.org/en/latest/api/crypto.html

Change-Id: I004e97dfe6444d0278013901005f104461bd8d1a
  • Loading branch information
kajinamit committed Mar 19, 2024
1 parent ebc729b commit 1681181
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
10 changes: 5 additions & 5 deletions barbican/plugin/util/translations.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

from cryptography.hazmat.backends import default_backend
from cryptography.hazmat.primitives import serialization
from OpenSSL import crypto
from cryptography import x509
from oslo_serialization import base64

from barbican import i18n as u # noqa
Expand Down Expand Up @@ -188,12 +188,12 @@ def _convert_public_der_to_pem(der):


def _convert_certificate_pem_to_der(pem):
cert = crypto.load_certificate(crypto.FILETYPE_PEM, pem)
der = crypto.dump_certificate(crypto.FILETYPE_ASN1, cert)
cert = x509.load_pem_x509_certificate(pem)
der = cert.public_bytes(serialization.Encoding.DER)
return der


def _convert_certificate_der_to_pem(der):
cert = crypto.load_certificate(crypto.FILETYPE_ASN1, der)
pem = crypto.dump_certificate(crypto.FILETYPE_PEM, cert)
cert = x509.load_der_x509_certificate(der)
pem = cert.public_bytes(serialization.Encoding.PEM)
return pem
1 change: 0 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ Paste>=2.0.2 # MIT
PasteDeploy>=1.5.0 # MIT
pbr!=2.1.0,>=2.0.0 # Apache-2.0
pecan!=1.0.2,!=1.0.3,!=1.0.4,!=1.2,>=1.0.0 # BSD
pyOpenSSL>=17.1.0 # Apache-2.0
ldap3>=1.0.2 # LGPLv3
keystonemiddleware>=9.5.0 # Apache-2.0
SQLAlchemy!=1.1.5,!=1.1.6,!=1.1.7,!=1.1.8,>=1.0.10 # MIT
Expand Down

0 comments on commit 1681181

Please sign in to comment.