Reputation: 21
I have a P12 file which I am trying to parse programmatically. I am successful in parsing it.
When I use the code as standalone and use -ssl and -crypto on command line it works fine. But when I use the same code in my application I get Undefined reference error : In function sk_X509_num undefined reference to OpenSSL_sk_num
and In function sk_X509_value undefined reference to OPENSSL_sk_value
Below is the code snippet I am using :
{
Bio *b = Bio_new(BIO_s_mem());
if(b != nullptr)
{
for(int i=0; i< sk_X509_num(ca);i++)
{
if(!PEM_write_bio_X509(b, sk_X509_value(ca,i)))
{
//some log message.....
}
else
{
//some code here
}
}
I have included in makefile the following flags : LDFLAGS+= -lssl -lcrypto The OPENSSL Version is 1.1.1g
Upvotes: 1
Views: 2151
Reputation: 21
I could finally resolve my own question:
It seems the functions sk_num
, sk_value
have been replaced with OpenSSL_sk_num
, OPENSSL_sk_value
. There is an issue with linking, somehow there symbols have been missed in symbol file in the version 1.1.g
.
I tried the following:
i) Using -lssl -lcrypto
on command line. This worked but when you use in the application and use the makefile
with the options -lssl -lcrypto
it fails with error undefined reference
.
ii) Downgraded the SSL
to the version 1.0.2
where in function sk_num
is not replaced with OPENSSL_sk_num
but it didn't work with the same failure.
iii) Success: So you need to define the functions for sk_num
, sk_value
, sk_pop_free
in the application where you are using these functions, which I took from the SSL version 1.1.n
, which is the latest in 1.1 series. I hope it helps the people facing this issue. I tried upgrading SSL
to version 1.1.n
but it didn't work for me.
Upvotes: 1