Ensuring the publicKey exists when generating an XML file