Refactor KS session creation and support CA certs

Change-Id: Ib3fc33b1825b16cc4537d979d5ab5ed0b39633d5