summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Gaynor <alex.gaynor@gmail.com>2017-06-29 15:31:39 -0700
committerPaul Kehrer <paul.l.kehrer@gmail.com>2017-06-29 17:31:39 -0500
commit10d30832462b4c44a4479dda462d4f35194a04a9 (patch)
treee8f5630ded7ffd30440fdb71b60be43157aefe6c
parent9939ba1658868b68654501aac24c97db8d9335ae (diff)
downloadpyopenssl-10d30832462b4c44a4479dda462d4f35194a04a9.tar.gz
Fixed #486 -- deprecate the backwards compat names (#643)
* Fixed #486 -- deprecate the backwards compat names * remove the docs for these, pretend they don't exist * CHANGELOG
-rw-r--r--CHANGELOG.rst3
-rw-r--r--doc/api/crypto.rst30
-rw-r--r--src/OpenSSL/SSL.py13
-rw-r--r--src/OpenSSL/crypto.py61
4 files changed, 64 insertions, 43 deletions
diff --git a/CHANGELOG.rst b/CHANGELOG.rst
index ee372c3..36d1b63 100644
--- a/CHANGELOG.rst
+++ b/CHANGELOG.rst
@@ -25,7 +25,8 @@ Backward-incompatible changes:
Deprecations:
^^^^^^^^^^^^^
-*none*
+
+- Deprecated the legacy "Type" aliases: ``ContextType``, ``ConnectionType``, ``PKeyType``, ``X509NameType``, ``X509ExtensionType``, ``X509ReqType``, ``X509Type``, ``X509StoreType``, ``CRLType``, ``PKCS7Type``, ``PKCS12Type``, ``NetscapeSPKIType``. The names without the "Type"-suffix should be used instead.
Changes:
diff --git a/doc/api/crypto.rst b/doc/api/crypto.rst
index 525553f..e7190ab 100644
--- a/doc/api/crypto.rst
+++ b/doc/api/crypto.rst
@@ -321,33 +321,3 @@ More information and a list of these digest names can be found in the ``EVP_Dige
This page can be found online for the latest version of OpenSSL:
https://www.openssl.org/docs/manmaster/man3/EVP_DigestInit.html
-
-Backwards compatible type names
--------------------------------
-
-When pyOpenSSL was originally written, the most current version of Python was 2.1.
-It made a distinction between classes and types.
-None of the versions of Python currently supported by pyOpenSSL still enforce that distinction:
-the type of an instance of an :class:`X509` object is now simply :class:`X509`.
-Originally, the type would have been :class:`X509Type`.
-These days, :class:`X509Type` and :class:`X509` are literally the same object.
-pyOpenSSL maintains these old names for backwards compatibility.
-
-Here's a table of these backwards-compatible names:
-
-====================== ==========================
-Type name Backwards-compatible name
-====================== ==========================
-:class:`X509` :class:`X509Type`
-:class:`X509Name` :class:`X509NameType`
-:class:`X509Req` :class:`X509ReqType`
-:class:`X509Store` :class:`X509StoreType`
-:class:`X509Extension` :class:`X509ExtensionType`
-:class:`PKey` :class:`PKeyType`
-:class:`PKCS7` :class:`PKCS7Type`
-:class:`PKCS12` :class:`PKCS12Type`
-:class:`NetscapeSPKI` :class:`NetscapeSPKIType`
-:class:`CRL` :class:`CRLType`
-====================== ==========================
-
-Some objects, such as :class:`Revoked`, don't have ``Type`` equivalents, because they were added after the restriction had been lifted.
diff --git a/src/OpenSSL/SSL.py b/src/OpenSSL/SSL.py
index 8bbde5b..85d6e76 100644
--- a/src/OpenSSL/SSL.py
+++ b/src/OpenSSL/SSL.py
@@ -5,6 +5,8 @@ from itertools import count, chain
from weakref import WeakValueDictionary
from errno import errorcode
+from cryptography.utils import deprecated
+
from six import binary_type as _binary_type
from six import integer_types as integer_types
from six import int2byte, indexbytes
@@ -1267,7 +1269,10 @@ class Context(object):
self._set_ocsp_callback(helper, data)
-ContextType = Context
+ContextType = deprecated(
+ Context, __name__,
+ "ContextType has been deprecated, use Context instead", DeprecationWarning
+)
class Connection(object):
@@ -2153,7 +2158,11 @@ class Connection(object):
_openssl_assert(rc == 1)
-ConnectionType = Connection
+ConnectionType = deprecated(
+ Connection, __name__,
+ "ConnectionType has been deprecated, use Connection instead",
+ DeprecationWarning
+)
# This is similar to the initialization calls at the end of OpenSSL/crypto.py
# but is exercised mostly by the Context initializer.
diff --git a/src/OpenSSL/crypto.py b/src/OpenSSL/crypto.py
index cdbcc22..ba918cc 100644
--- a/src/OpenSSL/crypto.py
+++ b/src/OpenSSL/crypto.py
@@ -12,6 +12,7 @@ from six import (
from cryptography import x509
from cryptography.hazmat.primitives.asymmetric import dsa, rsa
+from cryptography.utils import deprecated
from OpenSSL._util import (
ffi as _ffi,
@@ -313,7 +314,11 @@ class PKey(object):
return _lib.EVP_PKEY_bits(self._pkey)
-PKeyType = PKey
+PKeyType = deprecated(
+ PKey, __name__,
+ "PKeyType has been deprecated, use PKey instead",
+ DeprecationWarning
+)
class _EllipticCurve(object):
@@ -648,7 +653,11 @@ class X509Name(object):
return result
-X509NameType = X509Name
+X509NameType = deprecated(
+ X509Name, __name__,
+ "X509NameType has been deprecated, use X509Name instead",
+ DeprecationWarning
+)
class X509Extension(object):
@@ -816,7 +825,11 @@ class X509Extension(object):
return _ffi.buffer(char_result, result_length)[:]
-X509ExtensionType = X509Extension
+X509ExtensionType = deprecated(
+ X509Extension, __name__,
+ "X509ExtensionType has been deprecated, use X509Extension instead",
+ DeprecationWarning
+)
class X509Req(object):
@@ -985,7 +998,11 @@ class X509Req(object):
return result
-X509ReqType = X509Req
+X509ReqType = deprecated(
+ X509Req, __name__,
+ "X509ReqType has been deprecated, use X509Req instead",
+ DeprecationWarning
+)
class X509(object):
@@ -1436,7 +1453,11 @@ class X509(object):
return ext
-X509Type = X509
+X509Type = deprecated(
+ X509, __name__,
+ "X509Type has been deprecated, use X509 instead",
+ DeprecationWarning
+)
class X509StoreFlags(object):
@@ -1564,7 +1585,11 @@ class X509Store(object):
_openssl_assert(_lib.X509_STORE_set1_param(self._store, param) != 0)
-X509StoreType = X509Store
+X509StoreType = deprecated(
+ X509Store, __name__,
+ "X509StoreType has been deprecated, use X509Store instead",
+ DeprecationWarning
+)
class X509StoreContextError(Exception):
@@ -2175,7 +2200,11 @@ class CRL(object):
return dump_crl(type, self)
-CRLType = CRL
+CRLType = deprecated(
+ CRL, __name__,
+ "CRLType has been deprecated, use CRL instead",
+ DeprecationWarning
+)
class PKCS7(object):
@@ -2222,7 +2251,11 @@ class PKCS7(object):
return _ffi.string(string_type)
-PKCS7Type = PKCS7
+PKCS7Type = deprecated(
+ PKCS7, __name__,
+ "PKCS7Type has been deprecated, use PKCS7 instead",
+ DeprecationWarning
+)
class PKCS12(object):
@@ -2399,7 +2432,11 @@ class PKCS12(object):
return _bio_to_string(bio)
-PKCS12Type = PKCS12
+PKCS12Type = deprecated(
+ PKCS12, __name__,
+ "PKCS12Type has been deprecated, use PKCS12 instead",
+ DeprecationWarning
+)
class NetscapeSPKI(object):
@@ -2492,7 +2529,11 @@ class NetscapeSPKI(object):
_openssl_assert(set_result == 1)
-NetscapeSPKIType = NetscapeSPKI
+NetscapeSPKIType = deprecated(
+ NetscapeSPKI, __name__,
+ "NetscapeSPKIType has been deprecated, use NetscapeSPKI instead",
+ DeprecationWarning
+)
class _PassphraseHelper(object):