()
| 102 | } |
| 103 | |
| 104 | func (h HostnameError) Error() string { |
| 105 | c := h.Certificate |
| 106 | |
| 107 | var valid string |
| 108 | if ip := net.ParseIP(h.Host); ip != nil { |
| 109 | // Trying to validate an IP |
| 110 | if len(c.IPAddresses) == 0 { |
| 111 | return "x509: cannot validate certificate for " + h.Host + " because it doesn't contain any IP SANs" |
| 112 | } |
| 113 | for _, san := range c.IPAddresses { |
| 114 | if len(valid) > 0 { |
| 115 | valid += ", " |
| 116 | } |
| 117 | valid += san.String() |
| 118 | } |
| 119 | } else { |
| 120 | if c.hasSANExtension() { |
| 121 | valid = strings.Join(c.DNSNames, ", ") |
| 122 | } else { |
| 123 | valid = c.Subject.CommonName |
| 124 | } |
| 125 | } |
| 126 | |
| 127 | if len(valid) == 0 { |
| 128 | return "x509: certificate is not valid for any names, but wanted to match " + h.Host |
| 129 | } |
| 130 | return "x509: certificate is valid for " + valid + ", not " + h.Host |
| 131 | } |
| 132 | |
| 133 | // UnknownAuthorityError results when the certificate issuer is unknown |
| 134 | type UnknownAuthorityError struct { |
no outgoing calls
no test coverage detected