summaryrefslogtreecommitdiff
path: root/xmlsecurity
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2018-10-15 10:14:04 +0200
committerTomaž Vajngerl <quikee@gmail.com>2018-10-29 07:12:04 +0100
commit2077c5e4e10a8254206945520f084e6216464d6a (patch)
tree0c1c55917d427d9cab40e7039592f3e831119617 /xmlsecurity
parent951a65923c088a1e19a4073f3c26a3b564a0a922 (diff)
xmlsecurity: prevent seg. fault if there is no private key
Change-Id: I8c6917c63bbdcf0d9bb2eb1c89745186feb263f8 Reviewed-on: https://gerrit.libreoffice.org/61781 Reviewed-by: Tomaž Vajngerl <quikee@gmail.com> Tested-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'xmlsecurity')
-rw-r--r--xmlsecurity/source/xmlsec/nss/securityenvironment_nssimpl.cxx17
1 files changed, 12 insertions, 5 deletions
diff --git a/xmlsecurity/source/xmlsec/nss/securityenvironment_nssimpl.cxx b/xmlsecurity/source/xmlsec/nss/securityenvironment_nssimpl.cxx
index 86d68c522ed7..cae2675db64a 100644
--- a/xmlsecurity/source/xmlsec/nss/securityenvironment_nssimpl.cxx
+++ b/xmlsecurity/source/xmlsec/nss/securityenvironment_nssimpl.cxx
@@ -816,11 +816,18 @@ xmlSecKeysMngrPtr SecurityEnvironment_NssImpl::createKeysManager() {
{
if (auto pCERTCertificate = const_cast<CERTCertificate*>(pCertificate->getNssCert()))
{
- SECKEYPrivateKey* pPrivateKey = PK11_FindPrivateKeyFromCert(pCERTCertificate->slot, pCERTCertificate, nullptr);
- xmlSecKeyDataPtr pKeyData = xmlSecNssPKIAdoptKey(pPrivateKey, nullptr);
- xmlSecKeyPtr pKey = xmlSecKeyCreate();
- xmlSecKeySetValue(pKey, pKeyData);
- xmlSecNssAppDefaultKeysMngrAdoptKey(pKeysMngr, pKey);
+ if (pCERTCertificate && pCERTCertificate->slot)
+ {
+ SECKEYPrivateKey* pPrivateKey = PK11_FindPrivateKeyFromCert(pCERTCertificate->slot, pCERTCertificate, nullptr);
+ xmlSecKeyDataPtr pKeyData = xmlSecNssPKIAdoptKey(pPrivateKey, nullptr);
+ xmlSecKeyPtr pKey = xmlSecKeyCreate();
+ xmlSecKeySetValue(pKey, pKeyData);
+ xmlSecNssAppDefaultKeysMngrAdoptKey(pKeysMngr, pKey);
+ }
+ else
+ {
+ SAL_WARN("xmlsecurity.xmlsec", "Can't get the private key from the certificate.");
+ }
}
}