diff --git a/xmlsecurity/source/gpg/xmlsignature_gpgimpl.cxx b/xmlsecurity/source/gpg/xmlsignature_gpgimpl.cxx index 2eff021eb38f..fd2c5d1ebfbd 100644 --- a/xmlsecurity/source/gpg/xmlsignature_gpgimpl.cxx +++ b/xmlsecurity/source/gpg/xmlsignature_gpgimpl.cxx @@ -197,6 +197,8 @@ SAL_CALL XMLSignature_GpgImpl::generate( int nRet = xmlSecBase64Decode_ex(pKey, reinterpret_cast(pKey), xmlStrlen(pKey), &nWritten); if(nRet < 0) throw RuntimeException(u"The GpgME library failed to initialize for the OpenPGP protocol."_ustr); + + rCtx.clearSigningKeys(); // tdf#108828 Clear keys from previous unsuccessful sessions if( rCtx.addSigningKey( rCtx.key( reinterpret_cast(pKey), err, true)) )