Generate a private key if none.