Hello,
I am writing a script that is connecting to a HTTPS server. This server may have a self-signed certificate in which case I want to output a “friendly” error and allow the user to ignore this with a command line option.
The code I currently have looks like this:
if err != nil {
if strings.Contains(err.Error(), "cannot validate certificate") {
fmt.Println("Certicate verification failed. Use --insecure if you have a self-signed cert.")
os.Exit(6)
}
I feel like there should be a better way to do this, but so far my Google searches have not yielded any useful results. Maybe I am using the wrong keywords?
Thanks,
Lordy