CRYPTO_secure_malloc_init() fails without error message

Clay Shields clay at cs.georgetown.edu
Fri Feb 21 10:33:43 UTC 2020


Unfortunately that didn’t seem to be it. Updating my code to verify that I am root and running it:

Output:

The effective user id is  0
The real user id is  0
failed to init openssl secure heap the error may be (null)

Code:

#include <openssl/crypto.h>
#include <openssl/conf.h>
#include <openssl/evp.h>
#include <openssl/err.h>
#include <openssl/ssl.h>
#include <sys/types.h>
#include <unistd.h>
#include <stdio.h>

#define OPENSSL_MIN_HEAP_SIZE 65536


int main(){

  SSL_load_error_strings();
  SSL_library_init ();
  OpenSSL_add_all_algorithms ();

  uid_t uid, euid;
  uid = getuid();
  euid = geteuid();
  printf("The effective user id is  %d\n", (int) geteuid());
  printf("The real user id is  %d\n", (int) getuid());
  
  // Initialize the OPENSSL secure heap space for key storage
  int ret = CRYPTO_secure_malloc_init(OPENSSL_MIN_HEAP_SIZE, OPENSSL_MIN_HEAP_SIZE);
  
  if (ret == 0){
    printf("failed to init openssl secure heap the error may be %s\n", ERR_reason_error_string(ERR_get_error()));
  }

}


> On Feb 20, 2020, at 6:31 PM, Salz, Rich <rsalz at akamai.com> wrote:
> 
> Are you running as root?  If not, that's likely to be the problem.
> 



More information about the openssl-users mailing list