Skip to content

Instantly share code, notes, and snippets.

@romen
Last active June 13, 2019 19:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save romen/b95e99b3563a8ba4c27d88512c7932ff to your computer and use it in GitHub Desktop.
Save romen/b95e99b3563a8ba4c27d88512c7932ff to your computer and use it in GitHub Desktop.
Minimal working example for Ubuntu bug: https://bugs.launchpad.net/ubuntu/+source/openssl/+bug/1763870
#include <openssl/crypto.h>
#include <openssl/evp.h>
#pragma message "Compile time OpenSSL: " OPENSSL_VERSION_TEXT
#if OPENSSL_VERSION_NUMBER < 0x010100000
/* before 1.1.0 `OpenSSL_version` was `SSLeay_version` */
# define OpenSSL_version SSLeay_version
# define OPENSSL_VERSION SSLEAY_VERSION
#endif
#include <stdio.h>
int main(void)
{
EVP_PKEY_ASN1_METHOD *meth = NULL;
printf("runtime OpenSSL version: %s\n", OpenSSL_version(OPENSSL_VERSION));
meth = EVP_PKEY_asn1_new(NID_undef, 0, "pem_str", "info");
if (meth == NULL) {
fprintf(stderr, "EVP_PKEY_ans1_new() returned NULL\n");
}
else {
EVP_PKEY_asn1_set_item(meth, NULL, NULL);
}
printf("%p\n", EVP_PKEY_asn1_set_item);
return 0;
}
@romen
Copy link
Author

romen commented Jun 13, 2019

On a vanilla ubuntu:xenial Docker container (after installing build-essentials and libssl-dev):

root@6415fde92005:~# gcc mwe.c -lcrypto -ldl -lpthread
mwe.c:4:9: note: #pragma message: Compile time OpenSSL: OpenSSL 1.0.2g  1 Mar 2016
 #pragma message "Compile time OpenSSL: " OPENSSL_VERSION_TEXT
         ^
/tmp/ccBB3iLF.o: In function `main':
mwe.c:(.text+0x82): undefined reference to `EVP_PKEY_asn1_set_item'
mwe.c:(.text+0x87): undefined reference to `EVP_PKEY_asn1_set_item'
collect2: error: ld returned 1 exit status

Compilation succeeds but linking fails, because the EVP_PKEY_asn1_set_item symbol has been masked by package mantainers

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment