add support for ssl and make the secretKey optional