auth-plug.so: undefined symbol: EVP_MD_CTX_free 解决方法

Load error: /etc/mosquitto/auth-plug.so: undefined symbol: EVP_MD_CTX_free


编译auth-plug时候

cache.c: In function ‘sha_hash’:
cache.c:48:3: warning: implicit declaration of function ‘EVP_MD_CTX_new’ [-Wimplicit-function-declaration]
   EVP_MD_CTX *mdctx = EVP_MD_CTX_new();
   ^
cache.c:48:23: warning: initialization makes pointer from integer without a cast [enabled by default]
   EVP_MD_CTX *mdctx = EVP_MD_CTX_new();
                       ^
cache.c:53:3: warning: implicit declaration of function ‘EVP_MD_CTX_free’ [-Wimplicit-function-declaration]
   EVP_MD_CTX_free(mdctx);


原因是

HISTORY

EVP_MD_CTX became opaque in OpenSSL 1.1. Consequently, stack allocated EVP_MD_CTXs are no longer supported.

EVP_MD_CTX_create() and EVP_MD_CTX_destroy() were renamed to EVP_MD_CTX_new() and EVP_MD_CTX_free() in OpenSSL 1.1.

The link between digests and signing algorithms was fixed in OpenSSL 1.0 and later, so now EVP_sha1() can be used with RSA and DSA. The legacy EVP_dss1() was removed in OpenSSL 1.1.0



就是这个 mosquitto-auth-plug用的openssl1.1

刚好函数名变化

修改cache.c中 函数名称


static unsigned int sha_hash(const char *data, size_t size, unsigned char *out)
{
        unsigned int md_len = -1;
        const EVP_MD *md = EVP_get_digestbyname("SHA1");


        if (md != NULL) {
                //EVP_MD_CTX *mdctx = EVP_MD_CTX_new();
                EVP_MD_CTX *mdctx = EVP_MD_CTX_create();
                EVP_MD_CTX_init(mdctx);
                EVP_DigestInit_ex(mdctx, md, NULL);
                EVP_DigestUpdate(mdctx, data, size);
                EVP_DigestFinal_ex(mdctx, out, &md_len);
                //EVP_MD_CTX_free(mdctx);
                EVP_MD_CTX_destroy(mdctx);
        }

 


重新编译,使用,问题解决

你可能感兴趣的:(MQTT)