  Sterile neutrinos can be produced in the early universe via interactions with
their active counterparts. For small active-sterile mixing angles, thermal
equilibrium with the standard model plasma is not reached and sterile neutrinos
are only produced via flavor oscillations. We study in detail this regime,
taking into account matter potentials and decoherence effects caused by elastic
scatterings with the plasma. We find that resonant oscillations occurring at
temperatures $T\lesssim 10\,\mathrm{GeV}$ lead to a significant enhancement of
the sterile neutrino production rate. Taking this into account, we improve
constraints on the active-sterile mixing from Big Bang nucleosynthesis and the
cosmic microwave background, excluding mixing angles down to $\theta_s\sim
10^{-10}-10^{-16}$ for sterile neutrino masses in the $10\,\mathrm{MeV}$ to
$10\,\mathrm{GeV}$ range. We observe that if sterile neutrinos predominantly
decay into metastable hidden sector particles, this process provides a novel
dark matter production mechanism, consistent with the sterile neutrino origin
of light neutrino masses via the seesaw mechanism.
