d2i_X509: revert calling X509v3_cache_extensions()

Fixes #13754

Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/15705)
This commit is contained in:
Dr. David von Oheimb 2021-06-10 19:36:35 +02:00 committed by Dr. David von Oheimb
parent 25eeab019c
commit 49a54634ec

View File

@ -150,32 +150,9 @@ ASN1_SEQUENCE_ref(X509, x509_cb) = {
ASN1_EMBED(X509, signature, ASN1_BIT_STRING)
} ASN1_SEQUENCE_END_ref(X509, X509)
IMPLEMENT_ASN1_ALLOC_FUNCTIONS_fname(X509, X509, X509)
IMPLEMENT_ASN1_FUNCTIONS(X509)
IMPLEMENT_ASN1_DUP_FUNCTION(X509)
X509 *d2i_X509(X509 **a, const unsigned char **in, long len)
{
X509 *cert = NULL;
int free_on_error = a != NULL && *a == NULL;
cert = (X509 *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, (X509_it()));
/* Only cache the extensions if the cert object was passed in */
if (cert != NULL && a != NULL) { /* then cert == *a */
if (!ossl_x509v3_cache_extensions(cert)) {
if (free_on_error) {
*a = NULL;
X509_free(cert);
}
cert = NULL;
}
}
return cert;
}
int i2d_X509(const X509 *a, unsigned char **out)
{
return ASN1_item_i2d((const ASN1_VALUE *)a, out, (X509_it()));
}
/*
* This should only be used if the X509 object was embedded inside another
* asn1 object and it needs a libctx to operate.