4 * Copyright (C) AB Strakt
5 * See LICENSE for details.
7 * Export functions and exceptions from the SSL sub module.
8 * See the file RATIONALE for a short explanation of why this module was written.
13 #ifndef PyOpenSSL_SSL_H_
14 #define PyOpenSSL_SSL_H_
19 #include "connection.h"
21 #include "../crypto/crypto.h"
23 extern PyObject *ssl_Error, /* Base class */
24 *ssl_ZeroReturnError, /* Used with SSL_get_erorr */
25 *ssl_WantReadError, /* ... */
26 *ssl_WantWriteError, /* ... */
27 *ssl_WantX509LookupError, /* ... */
28 *ssl_SysCallError; /* Uses (errno,errstr) */
30 #define ssl_Context_New_NUM 0
31 #define ssl_Context_New_RETURN ssl_ContextObj *
32 #define ssl_Context_New_PROTO (int method)
34 #define ssl_Connection_New_NUM 1
35 #define ssl_Connection_New_RETURN ssl_ConnectionObj *
36 #define ssl_Connection_New_PROTO (ssl_ContextObj *ctx, PyObject *sock)
38 #define ssl_API_pointers 2
41 extern int _pyOpenSSL_tstate_key;
42 #endif /* WITH_THREAD */
46 extern ssl_Context_New_RETURN ssl_Context_New ssl_Context_New_PROTO;
47 extern ssl_Connection_New_RETURN ssl_Connection_New ssl_Connection_New_PROTO;
49 extern crypto_X509Obj* (*new_x509)(X509*, int);
50 extern crypto_X509NameObj* (*new_x509name)(X509_NAME*, int);
51 extern crypto_X509StoreObj* (*new_x509store)(X509_STORE*, int);
53 #else /* SSL_MODULE */
55 extern void **ssl_API;
57 #define ssl_Context_New \
58 (*(ssl_Context_New_RETURN (*)ssl_Context_New_PROTO) ssl_API[ssl_Context_New_NUM])
59 #define ssl_Connection_New \
60 (*(ssl_Connection_New_RETURN (*)ssl_Connection_New_PROTO) ssl_API[ssl_Connection_New_NUM])
62 #define import_SSL() \
64 PyObject *module = PyImport_ImportModule("OpenSSL.SSL"); \
65 if (module != NULL) { \
66 PyObject *module_dict = PyModule_GetDict(module); \
67 PyObject *c_api_object = PyDict_GetItemString(module_dict, "_C_API"); \
68 if (PyCObject_Check(c_api_object)) { \
69 ssl_API = (void **)PyCObject_AsVoidPtr(c_api_object); \
74 #endif /* SSL_MODULE */
76 #endif /* PyOpenSSL_SSL_H_ */