Handle both https and ssh urls

Extract functions from assertValid so that it can deal with either HTTPS
or SSH urls, depending on the value of RECEIVER_USE_SSH