emiago/sipgo

The example client bails out when compiled with Go 1.22.4

Closed this issue · 5 comments

I am not sure if this is related to Go 1.22 or in general an issue. When I do compile the example client and run it I do get:

Jun 28 08:51:11.427711 INF REGISTER sip:bob@127.0.0.1:5060 SIP/2.0
Jun 28 08:51:11.431174 INF Received status status=401
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x64579b]

goroutine 1 [running]:
github.com/icholy/digest.(*Credentials).String(0x0)
        /go/pkg/mod/github.com/icholy/digest@v0.1.22/credentials.go:76 +0x5b
main.main()
        /workspaces/opkald/example/client/main.go:97 +0xef6

In case I do handle the error I do get:

		// Reply with digest
		cred, err := digest.Digest(chal, digest.Options{
			Method:   req.Method.String(),
			URI:      recipient.Host,
			Username: *username,
			Password: *password,
		})
		if err != nil {
			panic(err)
		}

panic: digest: unsupported algorithm: "md5"

I can fix this by setting the Algorithm to "MD5" by hand....

		// Get WwW-Authenticate
		wwwAuth := res.GetHeader("WWW-Authenticate")
		chal, err := digest.ParseChallenge(wwwAuth.Value())
		if err != nil {
			log.Fatal().Str("wwwauth", wwwAuth.Value()).Err(err).Msg("Fail to parse challenge")
		}
		chal.Algorithm = "MD5"

I guess this should be fixed in the sipgo package

It looks like this is related to the digest package and the fact that asterisk does return a lower-case md5

I used asterisk in many testing, which version of asterisk are you using?

The version I do use at the moment is the Ubuntu 22.04 included version.
Asterisk 18.10.0~dfsg+~cs6.10.40431411-2
Maybe this behavior can be changed in the asterisk config?

@graugans have you tried newer versions?

Tested again and confirmed all works with asterisk 20