Handle either secure & non secure protocol.

This was previously hardcoded.