~rafael/gembro

901834c943a86c92c81b1125f373edf63d569f5a — RafaĆ«l L. Bekkema 3 years ago a5a1cd8
Add CommonName workaround
1 files changed, 7 insertions(+), 1 deletions(-)

M gemini/gemini.go
M gemini/gemini.go => gemini/gemini.go +7 -1
@@ 90,7 90,13 @@ func (client *Client) LoadURL(ctx context.Context, surl url.URL, skipVerify bool
		Config: &tls.Config{
			InsecureSkipVerify: true,
			VerifyConnection: func(state tls.ConnectionState) error {
				err := state.PeerCertificates[0].VerifyHostname(surl.Hostname())
				cert := state.PeerCertificates[0]
				// CommonName error workaround
				if strings.Contains(cert.Subject.CommonName, ".") {
					cert.DNSNames = append(cert.DNSNames, cert.Subject.CommonName)
					cert.Subject.CommonName = ""
				}
				err := cert.VerifyHostname(surl.Hostname())
				if err != nil {
					return err
				}