Direct and inverse spectral theorems for a class of canonical systems with two singular endpoints