Kaydet (Commit) 2077c5e4 authored tarafından Tomaž Vajngerl's avatar Tomaž Vajngerl Kaydeden (comit) Tomaž Vajngerl

xmlsecurity: prevent seg. fault if there is no private key

Change-Id: I8c6917c63bbdcf0d9bb2eb1c89745186feb263f8
Reviewed-on: https://gerrit.libreoffice.org/61781Reviewed-by: 's avatarTomaž Vajngerl <quikee@gmail.com>
Tested-by: 's avatarTomaž Vajngerl <quikee@gmail.com>
üst 951a6592
...@@ -816,11 +816,18 @@ xmlSecKeysMngrPtr SecurityEnvironment_NssImpl::createKeysManager() { ...@@ -816,11 +816,18 @@ xmlSecKeysMngrPtr SecurityEnvironment_NssImpl::createKeysManager() {
{ {
if (auto pCERTCertificate = const_cast<CERTCertificate*>(pCertificate->getNssCert())) if (auto pCERTCertificate = const_cast<CERTCertificate*>(pCertificate->getNssCert()))
{ {
SECKEYPrivateKey* pPrivateKey = PK11_FindPrivateKeyFromCert(pCERTCertificate->slot, pCERTCertificate, nullptr); if (pCERTCertificate && pCERTCertificate->slot)
xmlSecKeyDataPtr pKeyData = xmlSecNssPKIAdoptKey(pPrivateKey, nullptr); {
xmlSecKeyPtr pKey = xmlSecKeyCreate(); SECKEYPrivateKey* pPrivateKey = PK11_FindPrivateKeyFromCert(pCERTCertificate->slot, pCERTCertificate, nullptr);
xmlSecKeySetValue(pKey, pKeyData); xmlSecKeyDataPtr pKeyData = xmlSecNssPKIAdoptKey(pPrivateKey, nullptr);
xmlSecNssAppDefaultKeysMngrAdoptKey(pKeysMngr, pKey); xmlSecKeyPtr pKey = xmlSecKeyCreate();
xmlSecKeySetValue(pKey, pKeyData);
xmlSecNssAppDefaultKeysMngrAdoptKey(pKeysMngr, pKey);
}
else
{
SAL_WARN("xmlsecurity.xmlsec", "Can't get the private key from the certificate.");
}
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment