Spin connection and boundary states in a topological insulator