complain earlier if in FIPS-140 enforced mode

This commit is contained in:
Wade Simmons
2026-07-29 14:37:21 -04:00
parent 738b4fa044
commit 7c00c74550
+7 -2
View File
@@ -337,6 +337,11 @@ func newCertStateFromConfig(c *config.C, cipher string) (*CertState, error) {
return nil, err return nil, err
} }
if fips140.Enforced() && crt.Curve() != cert.Curve_P256 {
return nil, fmt.Errorf("pki: use of %s is not allowed in FIPS 140-only mode", crt.Curve())
}
switch crt.Version() { switch crt.Version() {
case cert.Version1: case cert.Version1:
if v1 != nil { if v1 != nil {
@@ -416,7 +421,7 @@ func newCertState(dv cert.Version, v1, v2 cert.Certificate, pkcs11backed bool, p
//NOTE: We do not currently have a method to verify a public private key pair when the private key is in an hsm //NOTE: We do not currently have a method to verify a public private key pair when the private key is in an hsm
} else { } else {
if err := v1.VerifyPrivateKey(privateKeyCurve, privateKey); err != nil { if err := v1.VerifyPrivateKey(privateKeyCurve, privateKey); err != nil {
return nil, fmt.Errorf("private key is not a pair with public key in nebula cert") return nil, fmt.Errorf("private key is not a pair with public key in nebula cert: %w", err)
} }
} }
@@ -441,7 +446,7 @@ func newCertState(dv cert.Version, v1, v2 cert.Certificate, pkcs11backed bool, p
//NOTE: We do not currently have a method to verify a public private key pair when the private key is in an hsm //NOTE: We do not currently have a method to verify a public private key pair when the private key is in an hsm
} else { } else {
if err := v2.VerifyPrivateKey(privateKeyCurve, privateKey); err != nil { if err := v2.VerifyPrivateKey(privateKeyCurve, privateKey); err != nil {
return nil, fmt.Errorf("private key is not a pair with public key in nebula cert") return nil, fmt.Errorf("private key is not a pair with public key in nebula cert: %w", err)
} }
} }