changed calling sequence + functions to open secure channel