core: fix race creating secret-key

Reading the secret key may result in generating and
writing a new key to disk.

Do that under the lock.
5 jobs for th/secret-key-with-machine-id in 7 minutes and 54 seconds (queued for 1 second)
Status Job ID Name Coverage
  Test
passed #61454
checkpatch

00:01:08

passed #61455
f28_build_autotools

00:07:54

passed #61456
f28_build_meson

00:04:09

passed #61457
f28_rpm_autotools_dbg

00:07:17

passed #61458
f28_rpm_meson_dbg

00:06:24