When setting the current certificate check that it has a corresponding private key. (cherry picked from commit 358d352a)