OpenSSL-1.0.x has changes in TXT_DB interface over the earlier openSSL releases.
Also looks that the IMPLEMENT_LHASH_* macros are not correctly implemented and
causes compile failures.
Some of the linux distributions to overcome the above problems trying to patch
openSSL SDK. For squid this is means that the current checks based on openSSL
version can not work.
This patch try to detect at configure time:
- if the TXT_DB uses the new implementation investigated in openSSL-1.0.x
releases
- If the IMPLEMENT_LHASH_* openSSL macros are correctly implemented.
Then uses the autoconf defines to implement the correct workarounds for used
openSSL SDK.
This is a Measurement Factory project
SQUID_STATE_ROLLBACK(check_SSL_get_certificate)
])
+
+
+dnl Try to handle TXT_DB related problems:
+dnl 1) The type of TXT_DB::data member changed in openSSL-1.0.1 version
+dnl 2) The IMPLEMENT_LHASH_* openSSL macros in openSSL-1.0.1 and later releases is not
+dnl implemented correctly and causes type conversion errors while compiling squid
+
+AC_DEFUN([SQUID_CHECK_OPENSSL_TXTDB],[
+ AH_TEMPLATE(SQUID_SSLTXTDB_PSTRINGDATA, "Define to 1 if the TXT_DB uses OPENSSL_PSTRING data member")
+ AH_TEMPLATE(SQUID_USE_SSLLHASH_HACK, "Define to 1 to use squid workaround for openssl IMPLEMENT_LHASH_* type conversion errors")
+
+ SQUID_STATE_SAVE(check_TXTDB)
+
+ LIBS="$LIBS $SSLLIB"
+ AC_MSG_CHECKING(whether the TXT_DB use OPENSSL_PSTRING data member)
+ AC_COMPILE_IFELSE([
+ AC_LANG_PROGRAM(
+ [
+ #include <openssl/txt_db.h>
+ ],
+ [
+ TXT_DB *db = NULL;
+ int i = sk_OPENSSL_PSTRING_num(db->data);
+ return 0;
+ ])
+ ],
+ [
+ AC_DEFINE(SQUID_SSLTXTDB_PSTRINGDATA, 1)
+ AC_MSG_RESULT([yes])
+ ],
+ [
+ AC_MSG_RESULT([no])
+ ],
+ [])
+
+ AC_MSG_CHECKING(whether the workaround for OpenSSL IMPLEMENT_LHASH_ macros should used)
+ AC_COMPILE_IFELSE([
+ AC_LANG_PROGRAM(
+ [
+ #include <openssl/txt_db.h>
+
+ static unsigned long index_serial_hash(const char **a){}
+ static int index_serial_cmp(const char **a, const char **b){}
+ static IMPLEMENT_LHASH_HASH_FN(index_serial_hash,const char **)
+ static IMPLEMENT_LHASH_COMP_FN(index_serial_cmp,const char **)
+ ],
+ [
+ TXT_DB *db = NULL;
+ TXT_DB_create_index(db, 1, NULL, LHASH_HASH_FN(index_serial_hash), LHASH_COMP_FN(index_serial_cmp));
+ ])
+ ],
+ [
+ AC_MSG_RESULT([no])
+ ],
+ [
+ AC_MSG_RESULT([yes])
+ AC_DEFINE(SQUID_USE_SSLLHASH_HACK, 1)
+ ],
+[])
+
+SQUID_STATE_ROLLBACK(check_TXTDB)
+])
if test "x$with_openssl" = "xyes"; then
SQUID_CHECK_OPENSSL_GETCERTIFICATE_WORKS
+SQUID_CHECK_OPENSSL_TXTDB
fi
AC_ARG_ENABLE(forw-via-db,
if (!db)
return;
-#if OPENSSL_VERSION_NUMBER >= 0x1000004fL
+#if SQUID_SSLTXTDB_PSTRINGDATA
for (int i = 0; i < sk_OPENSSL_PSTRING_num(db->data); ++i) {
const char ** current_row = ((const char **)sk_OPENSSL_PSTRING_value(db->data, i));
#else
void Ssl::CertificateDb::sq_TXT_DB_delete_row(TXT_DB *db, int idx)
{
char **rrow;
-#if OPENSSL_VERSION_NUMBER >= 0x1000004fL
+#if SQUID_SSLTXTDB_PSTRINGDATA
rrow = (char **)sk_OPENSSL_PSTRING_delete(db->data, idx);
#else
rrow = (char **)sk_delete(db->data, idx);
const Columns db_indexes[]={cnlSerial, cnlName};
for (unsigned int i = 0; i < countof(db_indexes); ++i) {
void *data = NULL;
-#if OPENSSL_VERSION_NUMBER >= 0x1000004fL
+#if SQUID_SSLTXTDB_PSTRINGDATA
if (LHASH_OF(OPENSSL_STRING) *fieldIndex = db->index[db_indexes[i]])
data = lh_OPENSSL_STRING_delete(fieldIndex, rrow);
#else
corrupt = true;
// Create indexes in db.
-#if OPENSSL_VERSION_NUMBER >= 0x1000004fL
- if (!corrupt && !TXT_DB_create_index(temp_db.get(), cnlSerial, NULL, LHASH_HASH_FN(index_serial), LHASH_COMP_FN(index_serial)))
- corrupt = true;
-
- if (!corrupt && !TXT_DB_create_index(temp_db.get(), cnlName, NULL, LHASH_HASH_FN(index_name), LHASH_COMP_FN(index_name)))
- corrupt = true;
-#else
if (!corrupt && !TXT_DB_create_index(temp_db.get(), cnlSerial, NULL, LHASH_HASH_FN(index_serial_hash), LHASH_COMP_FN(index_serial_cmp)))
corrupt = true;
if (!corrupt && !TXT_DB_create_index(temp_db.get(), cnlName, NULL, LHASH_HASH_FN(index_name_hash), LHASH_COMP_FN(index_name_cmp)))
corrupt = true;
-#endif
if (corrupt)
throw std::runtime_error("The SSL certificate database " + db_path + " is corrupted. Please rebuild");
return false;
bool removed_one = false;
-#if OPENSSL_VERSION_NUMBER >= 0x1000004fL
+#if SQUID_SSLTXTDB_PSTRINGDATA
for (int i = 0; i < sk_OPENSSL_PSTRING_num(db.get()->data); ++i) {
const char ** current_row = ((const char **)sk_OPENSSL_PSTRING_value(db.get()->data, i));
#else
if (!db)
return false;
-#if OPENSSL_VERSION_NUMBER >= 0x1000004fL
+#if SQUID_SSLTXTDB_PSTRINGDATA
if (sk_OPENSSL_PSTRING_num(db.get()->data) == 0)
#else
if (sk_num(db.get()->data) == 0)
#endif
return false;
-#if OPENSSL_VERSION_NUMBER >= 0x1000004fL
+#if SQUID_SSLTXTDB_PSTRINGDATA
const char **row = (const char **)sk_OPENSSL_PSTRING_value(db.get()->data, 0);
#else
const char **row = (const char **)sk_value(db.get()->data, 0);
if (!db)
return false;
-#if OPENSSL_VERSION_NUMBER >= 0x1000004fL
+#if SQUID_SSLTXTDB_PSTRINGDATA
for (int i = 0; i < sk_OPENSSL_PSTRING_num(db.get()->data); ++i) {
const char ** current_row = ((const char **)sk_OPENSSL_PSTRING_value(db.get()->data, i));
#else
/// Definitions required by openSSL, to use the index_* functions defined above
///with TXT_DB_create_index.
-#if OPENSSL_VERSION_NUMBER > 0x10000000L
- static unsigned long index_serial_LHASH_HASH(const void *a) {
+#if SQUID_USE_SSLLHASH_HACK
+ static unsigned long index_serial_hash_LHASH_HASH(const void *a) {
return index_serial_hash((const char **)a);
}
- static int index_serial_LHASH_COMP(const void *arg1, const void *arg2) {
+ static int index_serial_cmp_LHASH_COMP(const void *arg1, const void *arg2) {
return index_serial_cmp((const char **)arg1, (const char **)arg2);
}
- static unsigned long index_name_LHASH_HASH(const void *a) {
+ static unsigned long index_name_hash_LHASH_HASH(const void *a) {
return index_name_hash((const char **)a);
}
- static int index_name_LHASH_COMP(const void *arg1, const void *arg2) {
+ static int index_name_cmp_LHASH_COMP(const void *arg1, const void *arg2) {
return index_name_cmp((const char **)arg1, (const char **)arg2);
}
#else