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)
| 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. |
| 1777 | func 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 | |
| 1796 | func fipsAllowChain(chain []*x509.Certificate) bool { |
| 1797 | if len(chain) == 0 { |
no test coverage detected
searching dependent graphs…