]> git.ipfire.org Git - thirdparty/strongswan.git/commitdiff
openssl: Don't re-enter FIPS mode if we are already using it
authorMartin Willi <martin@revosec.ch>
Wed, 2 Apr 2014 13:16:15 +0000 (15:16 +0200)
committerMartin Willi <martin@revosec.ch>
Wed, 4 Jun 2014 13:53:11 +0000 (15:53 +0200)
If FIPS mode has been enabled by other means, under some environments it can't
be entered again. It fails with "FIPS mode already set". To avoid it, we first
check the mode before changing it.

src/libstrongswan/plugins/openssl/openssl_plugin.c

index 1ca1690ad4e3905cfe4c8b16ee64bef65236d6f7..a426cdcb3e3652c2f658d29c321fe40191918d4d 100644 (file)
@@ -526,9 +526,10 @@ plugin_t *openssl_plugin_create()
 #ifdef OPENSSL_FIPS
        if (fips_mode)
        {
-               if (!FIPS_mode_set(fips_mode))
+               if (FIPS_mode() != fips_mode && !FIPS_mode_set(fips_mode))
                {
-                       DBG1(DBG_LIB, "unable to set openssl FIPS mode(%d)", fips_mode);
+                       DBG1(DBG_LIB, "unable to set openssl FIPS mode(%d) from (%d)",
+                                fips_mode, FIPS_mode());
                        return NULL;
                }
        }