Golang crypto/x509.HostnameError() function example

package crypto/x509

HostnameError results when the set of authorized names doesn't match the requested name.

Golang crypto/x509.HostnameError() function usage example

 if innerError != nil {
  switch errorType := innerError.(type) {
  case x509.UnknownAuthorityError:
 fmt.Println("unknown authority error")
  case x509.HostnameError:
 fmt.Println("hostname error")
  case x509.CertificateInvalidError:
 fmt.Println("invalid certificate error")
  }
 }

Reference :

http://golang.org/pkg/crypto/x509/#HostnameError.Error

Advertisement