{"record":{"id":"38c2c8ff0963e05e","repo":"golang/go","slug":"server-s-certificate-is-not-allowed-in-fips-140-3","errorCode":null,"errorMessage":"server's certificate is not allowed in FIPS 140-3 mode","messagePattern":"server's certificate is not allowed in FIPS 140-3 mode","errorType":"exception","errorClass":"CertificateVerificationError","httpStatus":null,"severity":"critical","filePath":"src/crypto/tls/handshake_client.go","lineNumber":1179,"sourceCode":"\t\tfor _, cert := range certs[1:] {\n\t\t\topts.Intermediates.AddCert(cert)\n\t\t}\n\t\tchains, err := certs[0].Verify(opts)\n\t\tif err != nil {\n\t\t\tc.sendAlert(alertBadCertificate)\n\t\t\treturn &CertificateVerificationError{UnverifiedCertificates: certs, Err: err}\n\t\t}\n\n\t\tc.verifiedChains, err = fipsAllowedChains(chains)\n\t\tif err != nil {\n\t\t\tc.sendAlert(alertBadCertificate)\n\t\t\treturn &CertificateVerificationError{UnverifiedCertificates: certs, Err: err}\n\t\t}\n\t}\n\n\tif fips140tls.Required() && !isCertificateAllowedFIPS(certs[0]) {\n\t\tc.sendAlert(alertBadCertificate)\n\t\terr := errors.New(\"server's certificate is not allowed in FIPS 140-3 mode\")\n\t\treturn &CertificateVerificationError{UnverifiedCertificates: certs, Err: err}\n\t}\n\n\tswitch certs[0].PublicKey.(type) {\n\tcase *rsa.PublicKey, *ecdsa.PublicKey, ed25519.PublicKey:\n\tcase *mldsa.PublicKey:\n\t\tif c.vers < VersionTLS13 {\n\t\t\tc.sendAlert(alertIllegalParameter)\n\t\t\treturn errors.New(\"tls: server's certificate uses ML-DSA, which requires TLS 1.3\")\n\t\t}\n\tdefault:\n\t\tc.sendAlert(alertUnsupportedCertificate)\n\t\treturn fmt.Errorf(\"tls: server's certificate contains an unsupported type of public key: %T\", certs[0].PublicKey)\n\t}\n\n\tc.peerCertificates = certs\n\n\tif c.config.VerifyPeerCertificate != nil && !echRejected {","sourceCodeStart":1161,"sourceCodeEnd":1197,"githubUrl":"https://github.com/golang/go/blob/b6b368adc57c96c3151d224d172029f233ead2c3/src/crypto/tls/handshake_client.go#L1161-L1197","documentation":"Thrown when FIPS 140-3 mode is active (fips140tls.Required() returns true) and the server's leaf certificate uses algorithms or key types not on the FIPS 140-3 approved list. The error is wrapped in a CertificateVerificationError with UnverifiedCertificates set.","triggerScenarios":"Triggered after successful chain verification when fips140tls.Required() is true and isCertificateAllowedFIPS(certs[0]) returns false. The check applies to the leaf certificate's public key type and signature algorithm.","commonSituations":"Running a Go binary built with GOEXPERIMENT=fips140tls or in a FIPS-enabled environment. Server certificate uses algorithms not approved under FIPS 140-3 (e.g. Ed25519, certain curves, or disallowed hash functions). Mixing a FIPS-compliant Go client with a non-FIPS-compliant server infrastructure.","solutions":["Identify which certificate property violates FIPS — check the leaf cert's key type, curve, signature hash algorithm, and key size.","Replace the server certificate with one using FIPS-approved algorithms: RSA (2048+ bits), ECDSA P-256/P-384, SHA-256 or stronger.","If FIPS compliance is not actually required for this connection, disable FIPS-only mode in the build or runtime configuration.","Verify with: openssl x509 -in cert.pem -text to inspect the certificate's algorithm details."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Before connecting, verify FIPS mode requirement and server cert algorithm\nif fips140tls.Required() {\n    // Pre-fetch and inspect the server certificate\n    conn, err := net.DialTimeout(\"tcp\", addr, 5*time.Second)\n    if err == nil {\n        tlsConn := tls.Client(conn, &tls.Config{InsecureSkipVerify: true})\n        if err := tlsConn.Handshake(); err == nil {\n            certs := tlsConn.ConnectionState().PeerCertificates\n            if len(certs) > 0 && !isCertificateAllowedFIPS(certs[0]) {\n                log.Printf(\"server cert uses non-FIPS algorithm: %s\", certs[0].PublicKeyAlgorithm)\n            }\n        }\n        tlsConn.Close()\n    }\n}","typeGuard":null,"tryCatchPattern":"// FIPS cert errors are wrapped in CertificateVerificationError\nconn, err := tls.Dial(\"tcp\", addr, config)\nif err != nil {\n    var certErr *tls.CertificateVerificationError\n    if errors.As(err, &certErr) {\n        if strings.Contains(certErr.Err.Error(), \"FIPS 140-3\") {\n            log.Printf(\"server cert not FIPS-compliant: %v\", certErr.Err)\n            // Replace server cert or disable FIPS mode\n        }\n    }\n}","preventionTips":["Ensure server certificates use FIPS-approved algorithms (RSA 2048+, ECDSA P-256/P-384, SHA-256+) before deploying in FIPS environments.","Document FIPS requirements in infrastructure configuration.","Use FIPS-validated certificate authorities for all production certificates."],"tags":["tls","go","fips","certificate","compliance","security"],"backgroundTag":null,"analyzedSha":"b6b368adc57c96c3151d224d172029f233ead2c3","analyzedAt":"2026-08-12T00:22:02.250Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}