Search code examples
opensslx509

x509 structures no longer acessible in openSSL 1.1.1k


I'm porting some code from openssl 1.0.2n to 1.1.1k, and I'm having some access issues.

For example, I declare the type:

X509 *certificate;

And later, I do the following treatment, which gives me compilation errors like invalid use of incomplete type 'X509 {aka struct x509_st}' and forward declaration of 'X509 {aka struct x509_st}'

if ((certificate->cert_info) && (certificate->cert_info->signature) && (certificate->cert_info->signature->algorithm))
{
...
}

I understand that these structures are opaque now and I can no longer access them with pointers. How can I access them using openssl 1.1.1k? Thanks in advance!


Solution

  • You can get the certificate cert_info.signature data using X509_get0_tbs_sigalg():

    https://www.openssl.org/docs/man1.1.1/man3/X509_get0_tbs_sigalg.html

    This returns an X509_ALGOR object which you can query to get algorithm information using X509_ALGOR_get0:

    https://www.openssl.org/docs/man1.1.1/man3/X509_ALGOR_get0.html