301
302
py_pkey = crypto_PKey_New(pkey, 1);
302
303
if (py_pkey != NULL) {
303
py_pkey->only_public = 1;
304
py_pkey->only_public = 1;
305
306
return (PyObject *)py_pkey;
689
static char crypto_X509_get_extension_count_doc[] = "\n\
690
Get the number of extensions on the certificate.\n\
692
@return: Number of extensions as a Python integer\n\
696
crypto_X509_get_extension_count(crypto_X509Obj *self, PyObject *args) {
697
if (!PyArg_ParseTuple(args, ":get_extension_count")) {
701
return PyLong_FromLong((long)X509_get_ext_count(self->x509));
704
static char crypto_X509_get_extension_doc[] = "\n\
705
Get a specific extension of the certificate by index.\n\
707
@param index: The index of the extension to retrieve.\n\
708
@return: The X509Extension object at the specified index.\n\
712
crypto_X509_get_extension(crypto_X509Obj *self, PyObject *args) {
713
crypto_X509ExtensionObj *extobj;
717
if (!PyArg_ParseTuple(args, "i:get_extension", &loc)) {
721
/* will return NULL if loc is outside the range of extensions,
722
not registered as an error*/
723
ext = X509_get_ext(self->x509, loc);
725
PyErr_SetString(PyExc_IndexError, "extension index out of bounds");
726
return NULL; /* Should be reported as an IndexError ? */
729
extobj = PyObject_New(crypto_X509ExtensionObj, &crypto_X509Extension_Type);
730
extobj->x509_extension = X509_EXTENSION_dup(ext);
732
return (PyObject*)extobj;
689
736
* ADD_METHOD(name) expands to a correct PyMethodDef declaration
690
737
* { 'name', (PyCFunction)crypto_X509_name, METH_VARARGS }
715
762
ADD_METHOD(subject_name_hash),
716
763
ADD_METHOD(digest),
717
764
ADD_METHOD(add_extensions),
765
ADD_METHOD(get_extension),
766
ADD_METHOD(get_extension_count),
720
769
#undef ADD_METHOD