I have a codebase that was moved from openssl 1.0.1 to 1.1.0. One Project in it is producing errors when compiling. Some parts do compile without error but I stumbled upon forward declaration errors:
Foo/BarDH.cpp:37:28: error: member access into incomplete type 'dh_st'
nRes = BN_bn2bin( key->pub_key, &keyout[0] );
^
/usr/local/sysroot/usr/local/include/openssl/ossl_typ.h:104:16: note: forward declaration of 'dh_st'
typedef struct dh_st DH;
This is how files are included:
BarDH.cpp:
#include BarDH.hpp
[...]
BarDH.hpp:
#include <openssl/bn.h>
#include <openssl/dh.h>
#include <openssl/ec.h>
[...]
class BarDH{
BarDH(void);
virtual ~BarDH(void);
enum
{
MAX_PUBKEY_SIZE = 2048 / 8
};
DH* key;
};
Did anything change in how one is supposed to include files form openssl 1.0.1 to 1.1.0 or can anyone see what's going on here? Thank you!
OpenSSL 1.1.0 made most structures opaque, so you are no longer allowed to directly access the members of the DH struct. Use DH_get0_pub_key(key)
to get hold of the pub_key
value instead of key->pub_ke
y on line 37 of BarDH.cpp
https://www.openssl.org/docs/man1.1.1/man3/DH_get0_pub_key.html