From a.bonomi at endian.com Wed Oct 2 15:29:02 2013 From: a.bonomi at endian.com (Andrea Bonomi) Date: Wed, 02 Oct 2013 15:29:02 +0200 Subject: [pyOpenSSL-Users] [PATCH 0/1] new CRL methods Message-ID: <524C1F9E.6010309@endian.com> Hello, I developed a patch for adding the following methods to CRL class: get/set_issuer, get/set_lastUpdate, get/set_nextUpdate, get/set_version I hope this can be useful for someone else :-) Have a nice day, Andrea :: e n d i a n :: security with passion :: andrea bonomi :: senior software engineer ::http://www.endian.com ::a.bonomi at endian.com From a.bonomi at endian.com Wed Oct 2 15:29:11 2013 From: a.bonomi at endian.com (Andrea Bonomi) Date: Wed, 02 Oct 2013 15:29:11 +0200 Subject: [pyOpenSSL-Users] [PATCH 1/1] new CRL methods Message-ID: <524C1FA7.7000308@endian.com> diff -rupN pyOpenSSL-0.13.1.orig/OpenSSL/crypto/crl.c pyOpenSSL-0.13.1/OpenSSL/crypto/crl.c --- pyOpenSSL-0.13.1.orig/OpenSSL/crypto/crl.c 2011-08-15 00:06:11.000000000 +0200 +++ pyOpenSSL-0.13.1/OpenSSL/crypto/crl.c 2013-10-02 15:00:10.831665965 +0200 @@ -180,6 +180,171 @@ crypto_CRL_export(crypto_CRLObj *self, P return buffer; } +static char crypto_CRL_get_issuer_doc[] = "\n\ +Create an X509Name object for the issuer of the CRL\n\ +\n\ + at return: An X509Name object\n\ +"; + +static PyObject * +crypto_CRL_get_issuer(crypto_CRLObj *self, PyObject *args) +{ + crypto_X509NameObj *pyname; + X509_NAME *name; + + if (!PyArg_ParseTuple(args, ":get_issuer")) + return NULL; + + name = self->crl->crl->issuer; + pyname = crypto_X509Name_New(name, 0); + if (pyname != NULL) + { + pyname->parent_cert = (PyObject *)self; + Py_INCREF(self); + } + return (PyObject *)pyname; +} + + +static char crypto_CRL_set_issuer_doc[] = "\n\ +Set the issuer of the CRL\n\ +\n\ + at param issuer: The issuer name\n\ + at type issuer: L{X509Name}\n\ + at return: None\n\ +"; + +static PyObject * +crypto_CRL_set_issuer(crypto_CRLObj *self, PyObject *args) +{ + crypto_X509NameObj *issuer; + + if (!PyArg_ParseTuple(args, "O!:set_issuer", &crypto_X509Name_Type, + &issuer)) + return NULL; + + if (!X509_CRL_set_issuer_name(self->crl, issuer->x509_name)) + { + exception_from_error_queue(crypto_Error); + return NULL; + } + + Py_INCREF(Py_None); + return Py_None; +} + +static char crypto_CRL_get_lastUpdate_doc[] = "\n\ +Retrieve the time stamp for the CRL last update\n\ +\n\ + at return: A string giving the timestamp, in the format:\n\ +\n\ + YYYYMMDDhhmmssZ\n\ + YYYYMMDDhhmmss+hhmm\n\ + YYYYMMDDhhmmss-hhmm\n\ + or None if there is no value set.\n\ +"; + +static PyObject* +crypto_CRL_get_lastUpdate(crypto_CRLObj *self, PyObject *args) +{ + return _get_asn1_time( + ":get_lastUpdate", self->crl->crl->lastUpdate, args); +} + +static char crypto_CRL_set_lastUpdate_doc[] = "\n\ +Set the time stamp for the CRL last update\n\ +\n\ + at param when: A string giving the timestamp, in the format:\n\ +\n\ + YYYYMMDDhhmmssZ\n\ + YYYYMMDDhhmmss+hhmm\n\ + YYYYMMDDhhmmss-hhmm\n\ +\n\ + at return: None\n\ +"; + +static PyObject* +crypto_CRL_set_lastUpdate(crypto_CRLObj *self, PyObject *args) +{ + return _set_asn1_time( + BYTESTRING_FMT ":set_notBefore", + self->crl->crl->lastUpdate, args); +} + +static char crypto_CRL_get_nextUpdate_doc[] = "\n\ +Retrieve the time stamp for the CRL next update\n\ +\n\ + at return: A string giving the timestamp, in the format:\n\ +\n\ + YYYYMMDDhhmmssZ\n\ + YYYYMMDDhhmmss+hhmm\n\ + YYYYMMDDhhmmss-hhmm\n\ + or None if there is no value set.\n\ +"; + +static PyObject* +crypto_CRL_get_nextUpdate(crypto_CRLObj *self, PyObject *args) +{ + return _get_asn1_time( + ":get_nextUpdate", self->crl->crl->nextUpdate, args); +} + +static char crypto_CRL_set_nextUpdate_doc[] = "\n\ +Set the time stamp for the CRL next update\n\ +\n\ + at param when: A string giving the timestamp, in the format:\n\ +\n\ + YYYYMMDDhhmmssZ\n\ + YYYYMMDDhhmmss+hhmm\n\ + YYYYMMDDhhmmss-hhmm\n\ +\n\ + at return: None\n\ +"; + +static PyObject* +crypto_CRL_set_nextUpdate(crypto_CRLObj *self, PyObject *args) +{ + return _set_asn1_time( + BYTESTRING_FMT ":set_notBefore", + self->crl->crl->nextUpdate, args); +} + +static char crypto_CRL_get_version_doc[] = "\n\ +Return version number of the CRL\n\ +\n\ + at return: Version number as a Python integer\n\ +"; + +static PyObject * +crypto_CRL_get_version(crypto_CRLObj *self, PyObject *args) +{ + if (!PyArg_ParseTuple(args, ":get_version")) + return NULL; + + return PyLong_FromLong(ASN1_INTEGER_get(self->crl->crl->version)); +} + +static char crypto_CRL_set_version_doc[] = "\n\ +Set version number of the CRL\n\ +\n\ + at param version: The version number\n\ + at return: None\n\ +"; + +static PyObject * +crypto_CRL_set_version(crypto_CRLObj *self, PyObject *args) +{ + long version; + + if (!PyArg_ParseTuple(args, "i:set_version", &version)) + return NULL; + + X509_CRL_set_version(self->crl, version); + + Py_INCREF(Py_None); + return Py_None; +} + crypto_CRLObj * crypto_CRL_New(X509_CRL *crl) { crypto_CRLObj *self; @@ -204,6 +369,14 @@ crypto_CRL_New(X509_CRL *crl) { static PyMethodDef crypto_CRL_methods[] = { ADD_KW_METHOD(add_revoked), ADD_METHOD(get_revoked), + ADD_METHOD(get_issuer), + ADD_METHOD(set_issuer), + ADD_METHOD(get_lastUpdate), + ADD_METHOD(set_lastUpdate), + ADD_METHOD(get_nextUpdate), + ADD_METHOD(set_nextUpdate), + ADD_METHOD(get_version), + ADD_METHOD(set_version), ADD_KW_METHOD(export), { NULL, NULL } }; From exarkun at twistedmatrix.com Wed Oct 2 16:06:04 2013 From: exarkun at twistedmatrix.com (exarkun at twistedmatrix.com) Date: Wed, 02 Oct 2013 14:06:04 -0000 Subject: [pyOpenSSL-Users] [PATCH 0/1] new CRL methods In-Reply-To: <524C1F9E.6010309@endian.com> References: <524C1F9E.6010309@endian.com> Message-ID: <20131002140604.26068.1390798371.divmod.xquotient.2538@top> Hi Andrea, Thanks for sharing. If you'd like this to be incorporated into a future release of pyOpenSSL, please consider attaching it to a bug on . Also, please make future patches against trunk instead of releases. Jean-Paul On 01:29 pm, a.bonomi at endian.com wrote: >Hello, >I developed a patch for adding the following methods to CRL class: >get/set_issuer, get/set_lastUpdate, get/set_nextUpdate, get/set_version >I hope this can be useful for someone else :-) >Have a nice day, >Andrea > >:: e n d i a n >:: security with passion > >:: andrea bonomi >:: senior software engineer >::http://www.endian.com ::a.bonomi at endian.com > >_______________________________________________ >pyopenssl-users mailing list >pyopenssl-users at python.org >https://mail.python.org/mailman/listinfo/pyopenssl-users