sipgo icon indicating copy to clipboard operation
sipgo copied to clipboard

The example client bails out when compiled with Go 1.22.4

Open graugans opened this issue 8 months ago • 4 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:[email protected]: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/[email protected]/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

graugans avatar Jun 28 '24 07:06 graugans