We study the effect of a background flux string on the vacuum energy of mas
sive Dirac fermions in 2+1 dimensions confined to a finite spatial region b
y MIT boundary conditions. We treat two admissible selfadjoint extensions o
f the Hamiltonian and compare the results. In particular, for one of these
extensions, the Casimir energy turns out to be discontinuous at integer val
ues of the flux.