Phase space compression of the antiproton beam in ELENA will be performed by a new electron cooler the performance of which is greatly influenced by the properties of the electron beam. Careful design of the electron gun electrodes, the efficient recuperation of the electrons in the collector and the quality of the guiding magnetic field ensure an optimal performance of the cooler. The ELENA cooler is a compact device incorporating an adiabatic expansion to reduce the electron beam temperature as well as electrostatic bending plates for efficient collection of the electron beam. The transverse components of the longitudinal field in the cooling section must be kept small (Bt/Bl ≤ 5x10-4) to ensure a minimal perturbation to the electron beam transverse temperature. The longitudinal field itself needs to be as low as possible such that the distortion to the closed orbit of the circulating ion beam due to the short 90° toroids is kept as small as possible. We present the solutions chosen to design and construct a magnetic system within the above constraints as well as the setup used to measure and optimise the magnetic field components