diff options
author | Matěj Cepl <mcepl@cepl.eu> | 2017-09-26 21:51:27 +0200 |
---|---|---|
committer | Matěj Cepl <mcepl@cepl.eu> | 2017-09-29 20:40:33 +0200 |
commit | 9d8f13c72d09de87c69c66faaf0c15ca671ec56f (patch) | |
tree | 8f37b12694b2a501404d5b8d77d358de81135fe6 /SWIG/_pkcs7.i | |
parent | 1d004fcf50ca316f86cd95f64365f1d64fe9394d (diff) | |
download | m2crypto-9d8f13c72d09de87c69c66faaf0c15ca671ec56f.tar.gz |
Replace complicated PyErr_SetString construct with our own functoin (m2_PyErr_Msg).
Our C code is littered with a weird construct
PyErr_SetString(_x509_err, ERR_reason_error_string(ERR_get_error()))
I have rather made a more robust own function m2_PyErr_Msg(_x509_err)
Also add hand written error messages for functions which don't set the
error code themselves.
Fixes #177
Diffstat (limited to 'SWIG/_pkcs7.i')
-rw-r--r-- | SWIG/_pkcs7.i | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/SWIG/_pkcs7.i b/SWIG/_pkcs7.i index aa4f183..cdfd1d6 100644 --- a/SWIG/_pkcs7.i +++ b/SWIG/_pkcs7.i @@ -73,7 +73,7 @@ PyObject *pkcs7_decrypt(PKCS7 *pkcs7, EVP_PKEY *pkey, X509 *cert, int flags) { return NULL; } if (!PKCS7_decrypt(pkcs7, pkey, cert, bio, flags)) { - PyErr_SetString(_pkcs7_err, ERR_reason_error_string(ERR_get_error())); + m2_PyErr_Msg(_pkcs7_err); BIO_free(bio); return NULL; } @@ -103,15 +103,15 @@ PKCS7 *pkcs7_sign1(X509 *x509, EVP_PKEY *pkey, STACK_OF(X509) *stack, BIO *bio, PKCS7 *p7 = PKCS7_sign(NULL, NULL, stack, bio, flags | PKCS7_STREAM); if (p7 == NULL) { - PyErr_SetString(_pkcs7_err, ERR_reason_error_string(ERR_get_error())); + m2_PyErr_Msg(_pkcs7_err); return NULL; } if (PKCS7_sign_add_signer(p7, x509, pkey, hash, flags) == NULL) { - PyErr_SetString(_pkcs7_err, ERR_reason_error_string(ERR_get_error())); + m2_PyErr_Msg(_pkcs7_err); return NULL; } if (PKCS7_final(p7, bio, flags) != 1) { - PyErr_SetString(_pkcs7_err, ERR_reason_error_string(ERR_get_error())); + m2_PyErr_Msg(_pkcs7_err); return NULL; } return p7; @@ -140,7 +140,7 @@ PyObject *pkcs7_verify1(PKCS7 *pkcs7, STACK_OF(X509) *stack, X509_STORE *store, res = PKCS7_verify(pkcs7, stack, store, data, bio, flags); Py_END_ALLOW_THREADS if (!res) { - PyErr_SetString(_pkcs7_err, ERR_reason_error_string(ERR_get_error())); + m2_PyErr_Msg(_pkcs7_err); BIO_free(bio); return NULL; } @@ -199,7 +199,7 @@ PyObject *smime_read_pkcs7(BIO *bio) { p7=SMIME_read_PKCS7(bio, &bcont); Py_END_ALLOW_THREADS if (!p7) { - PyErr_SetString(_smime_err, ERR_reason_error_string(ERR_get_error())); + m2_PyErr_Msg(_smime_err); return NULL; } if (!(tuple=PyTuple_New(2))) { |