Skip to content

Unable to use crypto API without loading in config file #21470

Discussion options

You must be logged in to vote

Options

  • If OpenSSL < 1.1.0, use OPENSSL_no_config() to disable configuration file
  • If OpenSSL > 1.1.0, use OPENSSL_init_crypto() with OPENSSL_INIT_NO_LOAD_CONFIG option to suppress loading OpenSSL configuration files

Sample program

#include <stdio.h>
#include <stdlib.h>
#include <openssl/evp.h>
#include <openssl/conf.h>
#include <openssl/crypto.h>

int main() {
#if 0
    /* Use if OpenSSL < 1.1.0 */
    OPENSSL_no_config();
#endif
    OPENSSL_init_crypto(OPENSSL_INIT_NO_LOAD_CONFIG, NULL);
    EVP_MAC *mac = EVP_MAC_fetch(NULL, "HMAC", NULL);
    ...
    exit(EXIT_SUCCESS);
}

Without code to disable loading configuration

$ strace -e trace=open ./program
open("/etc/ld.so.cache", O_RDONLY…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by paulidale
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #20656 on July 16, 2023 21:59.