EMPTYCERT = data_file("nullcert.pem")
BADCERT = data_file("badcert.pem")
NONEXISTINGCERT = data_file("XXXnonexisting.pem")
+NONEXISTINGKEY = data_file("XXXnonexistingkey.pem")
BADKEY = data_file("badkey.pem")
NOKIACERT = data_file("nokia.pem")
NULLBYTECERT = data_file("nullbytecert.pem")
with self.assertRaises(OSError) as cm:
ctx.load_cert_chain(NONEXISTINGCERT)
self.assertEqual(cm.exception.errno, errno.ENOENT)
+ self.assertEqual(cm.exception.filename, NONEXISTINGCERT)
+ with self.assertRaises(OSError) as cm:
+ ctx.load_cert_chain(CERTFILE, keyfile=NONEXISTINGKEY)
+ self.assertEqual(cm.exception.errno, errno.ENOENT)
+ self.assertEqual(cm.exception.filename, NONEXISTINGKEY)
with self.assertRaisesRegex(ssl.SSLError, "PEM (lib|routines)"):
ctx.load_cert_chain(BADCERT)
with self.assertRaisesRegex(ssl.SSLError, "PEM (lib|routines)"):
/* the password callback has already set the error information */
}
else if (errno != 0) {
- PyErr_SetFromErrno(PyExc_OSError);
+ PyErr_SetFromErrnoWithFilename(PyExc_OSError,
+ PyBytes_AS_STRING(certfile_bytes));
ERR_clear_error();
}
else {
/* the password callback has already set the error information */
}
else if (errno != 0) {
- PyErr_SetFromErrno(PyExc_OSError);
+ PyErr_SetFromErrnoWithFilename(PyExc_OSError,
+ PyBytes_AS_STRING(keyfile_bytes ? keyfile_bytes : certfile_bytes));
ERR_clear_error();
}
else {