Skip to content

Commit

Permalink
OpenSSL 3 compatibility
Browse files Browse the repository at this point in the history
The function calls 'FIPS_mode()' and 'FIPS_mode_set()' have been removed from OpenSSL 3.0
  • Loading branch information
nosnilmot committed Apr 15, 2022
1 parent 4ee7fc4 commit 93adcff
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions c_src/fast_tls.c
Expand Up @@ -1265,6 +1265,7 @@ static ERL_NIF_TERM set_fips_mode_nif(ErlNifEnv *env, int argc,
if (!enif_get_int(env, argv[0], &enable))
return enif_make_badarg(env);

#if OPENSSL_VERSION_NUMBER < 0x30000000L
int fips_mode = FIPS_mode();

if ((fips_mode == 0 && enable != 0) ||
Expand All @@ -1273,14 +1274,22 @@ static ERL_NIF_TERM set_fips_mode_nif(ErlNifEnv *env, int argc,

if (ret != 1)
return ssl_error(env, "FIPS_mode_set() failed");
#else
#warning OpenSSL 3 FIPS support not implemented
#endif

return enif_make_atom(env, "ok");
}

static ERL_NIF_TERM get_fips_mode_nif(ErlNifEnv *env, int argc,
const ERL_NIF_TERM argv[]) {

#if OPENSSL_VERSION_NUMBER < 0x30000000L
const char *ret = FIPS_mode() ? "true" : "false";
#else
#warning OpenSSL 3 FIPS support not implemented
static const char *ret = "false";
#endif

return enif_make_atom(env, ret);
}
Expand Down

0 comments on commit 93adcff

Please sign in to comment.