Fix bugs in exchange certificates & exchange session keys