Skip to content

Commit

Permalink
Fix OpenSSL Runtime Check (#117)
Browse files Browse the repository at this point in the history
This check can not happen before the openssl
backend is initialized.
  • Loading branch information
dbenoit17 authored Sep 18, 2023
1 parent 7e08b6e commit 72bbe83
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 4 deletions.
4 changes: 1 addition & 3 deletions src/crypto/internal/boring/boring.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,6 @@ const (
OPENSSL_VERSION_3_0_0 = uint64(C.ulong(0x30000000))
)

func init() {
strictFIPSOpenSSLRuntimeCheck()
}

// Enabled controls whether FIPS crypto is enabled.
var enabled = false
Expand All @@ -58,6 +55,7 @@ func init() {

// Check if we can `dlopen` OpenSSL
if C._goboringcrypto_DLOPEN_OPENSSL() == C.NULL {
strictFIPSOpenSSLRuntimeCheck()
return
}

Expand Down
2 changes: 1 addition & 1 deletion src/crypto/internal/boring/strict_fips.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
var isStrictFIPS bool = true

func strictFIPSOpenSSLRuntimeCheck() {
if hostFIPSModeEnabled() && !Enabled() {
if hostFIPSModeEnabled() {
fmt.Fprintln(os.Stderr, "FIPS mode is enabled, but the required OpenSSL backend is unavailable")
os.Exit(1)
}
Expand Down

0 comments on commit 72bbe83

Please sign in to comment.