diff options
author | Laurens Van Houtven <_@lvh.cc> | 2014-06-17 17:06:34 +0200 |
---|---|---|
committer | Laurens Van Houtven <_@lvh.cc> | 2014-06-17 17:06:34 +0200 |
commit | 196195b794d11ca69055fa99cf01d71ec623dd5f (patch) | |
tree | eba1c9ccc010c4ae941de6ccf26147b0dbd8a139 | |
parent | 6e7dd43914bc3dafccba03d4dd2866c38e7000b8 (diff) | |
download | pyopenssl-196195b794d11ca69055fa99cf01d71ec623dd5f.tar.gz |
Use autodoc for X509Name
-rw-r--r-- | OpenSSL/crypto.py | 45 | ||||
-rw-r--r-- | doc/api/crypto.rst | 74 |
2 files changed, 41 insertions, 78 deletions
diff --git a/OpenSSL/crypto.py b/OpenSSL/crypto.py index 6cc5ff2..9af7927 100644 --- a/OpenSSL/crypto.py +++ b/OpenSSL/crypto.py @@ -427,11 +427,35 @@ def get_elliptic_curve(name): class X509Name(object): + """ + An X.509 Distinguished Name. + + :ivar countryName: The country of the entity. + :ivar C: Alias for :py:attr:`countryName`. + + :ivar stateOrProvinceName: The state or province of the entity. + :ivar ST: Alias for :py:attr:`stateOrProvinceName`. + + :ivar localityName: The locality of the entity. + :ivar L: Alias for :py:attr:`localityName`. + + :ivar organizationName: The organization name of the entity. + :ivar O: Alias for :py:attr:`organizationName`. + + :ivar organizationalUnitName: The organizational unit of the entity. + :ivar OU: Alias for :py:attr:`organizationalUnitName` + + :ivar commonName: The common name of the entity. + :ivar CN: Alias for :py:attr:`commonName`. + + :ivar emailAddress: The e-mail address of the entity. + """ def __init__(self, name): """ Create a new X509Name, copying the given X509Name instance. - :param name: An X509Name object to copy + :param name: The name to copy. + :type name: :py:class:`X509Name` """ name = _lib.X509_NAME_dup(name._name) self._name = _ffi.gc(name, _lib.X509_NAME_free) @@ -550,19 +574,23 @@ class X509Name(object): def hash(self): """ - Return the hash value of this name + Return an integer representation of the first four bytes of the + MD5 digest of the DER representation of the name. - :return: None + This is the Python equivalent of OpenSSL's ``X509_NAME_hash``. + + :return: The (integer) hash of this name. + :rtype: :py:class:`int` """ return _lib.X509_NAME_hash(self._name) def der(self): """ - Return the DER encoding of this name + Return the DER encoding of this name. - :return: A :py:class:`bytes` instance giving the DER encoded form of - this name. + :return: The DER encoded form of this name. + :rtype: :py:class:`bytes` """ result_buffer = _ffi.new('unsigned char**') encode_result = _lib.i2d_X509_NAME(self._name, result_buffer) @@ -577,9 +605,10 @@ class X509Name(object): def get_components(self): """ - Returns the split-up components of this name. + Returns the components of this name, as a sequence of 2-tuples. - :return: List of tuples (name, value). + :return: The components of this name. + :rtype: :py:class:`list` of ``name, value`` tuples. """ result = [] for i in range(_lib.X509_NAME_entry_count(self._name)): diff --git a/doc/api/crypto.rst b/doc/api/crypto.rst index e3d4f14..9beadce 100644 --- a/doc/api/crypto.rst +++ b/doc/api/crypto.rst @@ -11,15 +11,6 @@ A class representing X.509 certificates. - -.. py:class:: X509Name(x509name) - - A class representing X.509 Distinguished Names. - - This constructor creates a copy of *x509name* which should be an - instance of :py:class:`X509Name`. - - .. py:class:: X509Req() A class representing X.509 certificate requests. @@ -322,7 +313,6 @@ X509 objects have the following methods: by OpenSSL (by EVP_get_digestbyname, specifically). For example, :py:const:`"md5"` or :py:const:`"sha1"`. - .. py:method:: X509.add_extensions(extensions) Add the extensions in the sequence *extensions* to the certificate. @@ -351,66 +341,10 @@ X509 objects have the following methods: X509Name objects ---------------- -X509Name objects have the following methods: - -.. py:method:: X509Name.hash() - - Return an integer giving the first four bytes of the MD5 digest of the DER - representation of the name. - - -.. py:method:: X509Name.der() - - Return a string giving the DER representation of the name. - - -.. py:method:: X509Name.get_components() - - Return a list of two-tuples of strings giving the components of the name. - - -X509Name objects have the following members: - -.. py:attribute:: X509Name.countryName - - The country of the entity. :py:attr:`C` may be used as an alias for - :py:attr:`countryName`. - - -.. py:attribute:: X509Name.stateOrProvinceName - - The state or province of the entity. :py:attr:`ST` may be used as an alias for - :py:attr:`stateOrProvinceName`. - - -.. py:attribute:: X509Name.localityName - - The locality of the entity. :py:attr:`L` may be used as an alias for - :py:attr:`localityName`. - - -.. py:attribute:: X509Name.organizationName - - The organization name of the entity. :py:attr:`O` may be used as an alias for - :py:attr:`organizationName`. - - -.. py:attribute:: X509Name.organizationalUnitName - - The organizational unit of the entity. :py:attr:`OU` may be used as an alias for - :py:attr:`organizationalUnitName`. - - -.. py:attribute:: X509Name.commonName - - The common name of the entity. :py:attr:`CN` may be used as an alias for - :py:attr:`commonName`. - - -.. py:attribute:: X509Name.emailAddress - - The e-mail address of the entity. - +.. autoclass:: X509Name + :members: + :special-members: + :exclude-members: __repr__, __getattr__, __weakref__ .. _openssl-x509req: |