Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Certificate verification error when connecting from Go #1610

Open
muety opened this issue Dec 15, 2024 · 0 comments
Open

Certificate verification error when connecting from Go #1610

muety opened this issue Dec 15, 2024 · 0 comments

Comments

@muety
Copy link

muety commented Dec 15, 2024

When attempting to send mail from a Go application via an smtp4dev instance that runs with a self-signed certificate, I'm getting the following error:

tls: failed to verify certificate: x509: certificate relies on legacy Common Name field, use SANs instead

There used to be a flag that you could set to instruct Go to ignore this error (see here), but apparently it has been removed after Go 1.17.

Minimal code example:

package main

import (
	"fmt"
	"net/smtp"
	"os"
)

func main() {
	auth := smtp.PlainAuth("", "admin", "admin", "localhost.localdomain")
	err := smtp.SendMail("localhost.localdomain:2525", auth, "admin@example.org", []string{ "user@example.org" }, []byte("Just a test"))
	if err != nil {
		fmt.Println(err)
		os.Exit(1)
	}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant