OpenSSL: don't use direct access to the internal of X509_OBJECT

OpenSSL 1.1 does not allow us to directly access the internal of
any data type, including X509_OBJECT. We have to use the defined
functions to do so.

Compatibility with OpenSSL 1.0 is kept by defining the corresponding
functions when they are not found in the library.

Signed-off-by: Emmanuel Deloget <logout@free.fr>
Acked-by: Steffan Karger <steffan.karger@fox-it.com>
Message-Id: <c849c9778d2b2faa4eb4d31367b37d993da5eb85.1487368114.git.logout@free.fr>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg14080.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
This commit is contained in:
Emmanuel Deloget 2017-02-17 23:00:42 +01:00 committed by Gert Doering
parent f05665df41
commit 47191f4989
4 changed files with 36 additions and 4 deletions

View File

@ -903,6 +903,8 @@ if test "${enable_crypto}" = "yes" -a "${with_crypto_library}" = "openssl"; then
SSL_CTX_get_default_passwd_cb \
SSL_CTX_get_default_passwd_cb_userdata \
X509_STORE_get0_objects \
X509_OBJECT_free \
X509_OBJECT_get_type \
],
,
[]

View File

@ -86,4 +86,35 @@ X509_STORE_get0_objects(X509_STORE *store)
}
#endif
#if !defined(HAVE_X509_OBJECT_FREE)
/**
* Destroy a X509 object
*
* @param obj X509 object
*/
static inline void
X509_OBJECT_free(X509_OBJECT *obj)
{
if (obj)
{
X509_OBJECT_free_contents(obj);
OPENSSL_free(obj);
}
}
#endif
#if !defined(HAVE_X509_OBJECT_GET_TYPE)
/**
* Get the type of an X509 object
*
* @param obj X509 object
* @return The underlying object type
*/
static inline int
X509_OBJECT_get_type(const X509_OBJECT *obj)
{
return obj ? obj->type : X509_LU_FAIL;
}
#endif
#endif /* OPENSSL_COMPAT_H_ */

View File

@ -905,11 +905,10 @@ backend_tls_ctx_reload_crl(struct tls_root_ctx *ssl_ctx, const char *crl_file,
{
X509_OBJECT *obj = sk_X509_OBJECT_value(objs, i);
ASSERT(obj);
if (obj->type == X509_LU_CRL)
if (X509_OBJECT_get_type(obj) == X509_LU_CRL)
{
sk_X509_OBJECT_delete(objs, i);
X509_OBJECT_free_contents(obj);
OPENSSL_free(obj);
X509_OBJECT_free(obj);
}
}

View File

@ -722,7 +722,7 @@ tls_verify_crl_missing(const struct tls_options *opt)
{
X509_OBJECT *obj = sk_X509_OBJECT_value(objs, i);
ASSERT(obj);
if (obj->type == X509_LU_CRL)
if (X509_OBJECT_get_type(obj) == X509_LU_CRL)
{
return false;
}