Skip to content

Commit

Permalink
Fix fips module usage
Browse files Browse the repository at this point in the history
  • Loading branch information
dwoz committed Sep 9, 2023
1 parent 0fc6365 commit c872d88
Showing 1 changed file with 16 additions and 10 deletions.
26 changes: 16 additions & 10 deletions relenv/runtime.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ def debug(string):
"""
if os.environ.get("RELENV_DEBUG"):
print(string)
sys.stdout.flush()


def relenv_root():
Expand Down Expand Up @@ -791,17 +792,12 @@ def setup_openssl():
Configure openssl certificate locations.
"""
if "OPENSSL_MODULES" not in os.environ and sys.platform != "win32":
# First load relenv's legacy provider then set the modules directory to
# the system's modules directory if we can determine it.
set_openssl_modules_dir(str(sys.RELENV / "lib" / "ossl-modules"))
# First try and load the system's fips provider. Then load relenv's
# legacy and default providers. The fips provider must be loaded first
# in order OpenSSl to work properly..

if load_openssl_provider("default") == 0:
debug("Unable to load the default openssl provider")
if load_openssl_provider("legacy") == 0:
debug("Unable to load the legacy openssl provider")

# Now we try and determine the system's openssl modules directory. This
# is so we can use the system installed fips provider if it configured.
# Try and determine the system's openssl modules directory. This is so
# we can use the system installed fips provider if it configured.
openssl_bin = shutil.which("openssl")
proc = subprocess.run(
[openssl_bin, "version", "-m"],
Expand All @@ -823,6 +819,16 @@ def setup_openssl():
return
path = directory.strip().strip('"')
set_openssl_modules_dir(path)
if load_openssl_provider("fips") == 0:
debug("Unable to load the fips openssl provider")

set_openssl_modules_dir(str(sys.RELENV / "lib" / "ossl-modules"))

if load_openssl_provider("default") == 0:
debug("Unable to load the default openssl provider")
if load_openssl_provider("legacy") == 0:
debug("Unable to load the legacy openssl provider")

# Use system openssl dirs
# XXX Should we also setup SSL_CERT_FILE, OPENSSL_CONF &
# OPENSSL_CONF_INCLUDE?
Expand Down

0 comments on commit c872d88

Please sign in to comment.