4 * Copyright (C) AB Strakt
5 * See LICENSE for details.
7 * X.509 Store handling, mostly thin wrapping.
8 * See the file RATIONALE for a short explanation of why this module was written.
14 static char crypto_X509Store_add_cert_doc[] = "\n\
17 @param cert: The certificate to add\n\
22 crypto_X509Store_add_cert(crypto_X509StoreObj *self, PyObject *args)
26 if (!PyArg_ParseTuple(args, "O!:add_cert", &crypto_X509_Type, &cert))
29 if (!X509_STORE_add_cert(self->x509_store, cert->x509))
31 exception_from_error_queue(crypto_Error);
41 * ADD_METHOD(name) expands to a correct PyMethodDef declaration
42 * { 'name', (PyCFunction)crypto_X509Store_name, METH_VARARGS }
45 #define ADD_METHOD(name) \
46 { #name, (PyCFunction)crypto_X509Store_##name, METH_VARARGS, crypto_X509Store_##name##_doc }
47 static PyMethodDef crypto_X509Store_methods[] =
56 * Constructor for X509Store, never called by Python code directly
58 * Arguments: name - A "real" X509_STORE object
59 * dealloc - Boolean value to specify whether the destructor should
60 * free the "real" X509_STORE object
61 * Returns: The newly created X509Store object
64 crypto_X509Store_New(X509_STORE *store, int dealloc)
66 crypto_X509StoreObj *self;
68 self = PyObject_New(crypto_X509StoreObj, &crypto_X509Store_Type);
73 self->x509_store = store;
74 self->dealloc = dealloc;
80 * Deallocate the memory used by the X509Store object
82 * Arguments: self - The X509Store object
86 crypto_X509Store_dealloc(crypto_X509StoreObj *self)
88 /* Sometimes we don't have to dealloc this */
90 X509_STORE_free(self->x509_store);
96 PyTypeObject crypto_X509Store_Type = {
97 PyOpenSSL_HEAD_INIT(&PyType_Type, 0)
99 sizeof(crypto_X509StoreObj),
101 (destructor)crypto_X509Store_dealloc,
107 NULL, /* as_number */
108 NULL, /* as_sequence */
109 NULL, /* as_mapping */
115 NULL, /* as_buffer */
120 NULL, /* tp_richcompare */
121 0, /* tp_weaklistoffset */
123 NULL, /* tp_iternext */
124 crypto_X509Store_methods, /* tp_methods */
129 * Initialize the X509Store part of the crypto module
131 * Arguments: module - The crypto module
135 init_crypto_x509store(PyObject *module)
137 if (PyType_Ready(&crypto_X509Store_Type) < 0) {
141 if (PyModule_AddObject(module, "X509StoreType", (PyObject *)&crypto_X509Store_Type) != 0) {