Handle + in cert when parsing intorducer url
A cert is a base64 encoded string. It can also contain a +
. We parse the introducer url with net.Parse
. It replaces the + with a space which breaks obfv4:
func TestNewIntroducerFromURLWithPlus(t *testing.T) {
url := "obfsvpnintro://localhost:4430/?cert=vhD5BObzfsxxnUZmi78iY/iNeZ77u3cWiAMTA+oTSpa0hGgdWpvSrTb0cb5CaYoZM7oWQw&fqdn=localhost&kcp=0"
intro, err := NewIntroducerFromURL(url)
assert.NoError(t, err, "NewIntroducerFromURL failed")
assert.NotNil(t, intro, "intro should not be nil")
log.Info().Msgf("There are no errors but the cert has a spacet: %s", intro.Cert)
}
=== RUN TestNewIntroducerFromURLWithPlus
{"level":"info","time":"2024-09-17T09:36:54+02:00","message":"There are no errors but the cert has a spacet: vhD5BObzfsxxnUZmi78iY/iNeZ77u3cWiAMTA oTSpa0hGgdWpvSrTb0cb5CaYoZM7oWQw"}
--- PASS: TestNewIntroducerFromURLWithPlus (0.00s)
We need something better than net.Parse. I could not find something better on the first look. Replace(" ", "+") would be a dirty hack (but working).