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

Closed
muety opened this issue Dec 15, 2024 · 4 comments
Closed

Certificate verification error when connecting from Go #1610

muety opened this issue Dec 15, 2024 · 4 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, "[email protected]", []string{ "[email protected]" }, []byte("Just a test"))
	if err != nil {
		fmt.Println(err)
		os.Exit(1)
	}
}
@muety
Copy link
Author

muety commented Jan 20, 2025

Would love to get this fixed! It's pretty much a deal breaker for me right now.

@rnwood Is the project still being maintained? I see only very few commits recently and a lot of open PRs 🤔

@rnwood
Copy link
Owner

rnwood commented Jan 20, 2025 via email

@rnwood
Copy link
Owner

rnwood commented Jan 23, 2025

This issue should be resolved in the latest pre release builds. Please let me know if this is not the case with your use case.

Thanks
Rob

@muety
Copy link
Author

muety commented Jan 23, 2025

Wow, thanks a lot for fixing this! Seems to first at first glance. I'm still getting a certificate validation error due to using a self-signed cert:

tls: failed to verify certificate: x509: certificate signed by unknown authority

But I presume that can be worked around by configuring the client to trust it anyway (specifically for Go, see here).

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

2 participants