Josephson junctions fabricated on the surface of three-dimensional topological insulators (TI) show a few unusual properties distinct from conventional Josephson junctions. In these devices, the Josephson coupling and the supercurrent are mediated by helical metal, the two-dimensional surface of the TI. A line junction of this kind is known to support Andreev bound states at zero energy for phase bias pi, and consequently the so-called fractional ac Josephson effect. Motivated by recent experiments on TI-based Josephson junctions, here we describe a convenient algorithm to compute the bound state spectrum and the current-phase relation for junctions with finite length and width. We present analytical results for the bound state spectrum, and discuss the dependence of the current-phase relation on the length and width of the junction, the chemical potential of the helical metal, and temperature. A thorough understanding of the current-phase relation may help in designing topological superconducting qubits and manipulating Majorana fermions.