MCPcopy Create free account
hub / github.com/XTLS/REALITY / fipsAllowedChains

Function fipsAllowedChains

common.go:1777–1794  ·  view source on GitHub ↗

fipsAllowedChains returns chains that are allowed to be used in a TLS connection based on the current fips140tls enforcement setting. If fips140tls is not required, the chains are returned as-is with no processing. Otherwise, the returned chains are filtered to only those allowed by FIPS 140-3. If

(chains [][]*x509.Certificate)

Source from the content-addressed store, hash-verified

1775// Otherwise, the returned chains are filtered to only those allowed by FIPS 140-3.
1776// If this results in no chains it returns an error.
1777func fipsAllowedChains(chains [][]*x509.Certificate) ([][]*x509.Certificate, error) {
1778 if !fips140tls.Required() {
1779 return chains, nil
1780 }
1781
1782 permittedChains := make([][]*x509.Certificate, 0, len(chains))
1783 for _, chain := range chains {
1784 if fipsAllowChain(chain) {
1785 permittedChains = append(permittedChains, chain)
1786 }
1787 }
1788
1789 if len(permittedChains) == 0 {
1790 return nil, errors.New("tls: no FIPS compatible certificate chains found")
1791 }
1792
1793 return permittedChains, nil
1794}
1795
1796func fipsAllowChain(chain []*x509.Certificate) bool {
1797 if len(chain) == 0 {

Callers 2

Calls 2

RequiredFunction · 0.92
fipsAllowChainFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…