From: Piotr Sawicki
Date: Mon, 18 Sep 2017 13:59:15 +0000 (+0200)
Subject: Let the import function return list with real aliases
X-Git-Tag: submit/tizen/20180403.094824~2
X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=9dcf67edda9be3f12f9b18b1f983677614c4442e;p=platform%2Fcore%2Fsecurity%2Fcert-svc.git
Let the import function return list with real aliases
To be consistent with certsvc_pkcs12_load_certificate_list_from_store(),
the new function certsvc_pkcs12_import_from_file_to_store_ret_list()
should return the list of intermediate certificates with aliases taken
from an imported certificate chain.
Change-Id: I22d31c59fc8943b9e08113a6ac290bfe1867a1eb
---
diff --git a/src/vcore/pkcs12.cpp b/src/vcore/pkcs12.cpp
index 3e0cc70..5734004 100644
--- a/src/vcore/pkcs12.cpp
+++ b/src/vcore/pkcs12.cpp
@@ -296,9 +296,9 @@ int installChainCert(CertStoreType storeType,
const std::string &cert,
const std::string &gname,
const std::string &endCertGname,
+ const std::string &commonName,
CertType type)
{
- std::string commonName = getCommonName(type, cert);
return vcore_client_install_certificate_to_store(
storeType,
gname.c_str(),
@@ -710,19 +710,19 @@ int insertToStore(CertStoreType storeTypes,
}
for (size_t i = 0; i < ncerts; i++) {
- if (i == ncerts - 1)
- result = installChainCert(storeType, certChainBuffer[i], certChainName[i], endCertName,
- P12_TRUSTED);
- else
- result = installChainCert(storeType, certChainBuffer[i], certChainName[i], endCertName,
- P12_INTERMEDIATE);
+ CertType type = (i == ncerts - 1) ? P12_TRUSTED : P12_INTERMEDIATE;
+
+ std::string commonName = getCommonName(type, certChainBuffer[i]);
+
+ result = installChainCert(storeType, certChainBuffer[i], certChainName[i], endCertName,
+ commonName, type);
if (result != CERTSVC_SUCCESS) {
LogError("Failed to install the ca certificates. result : " << result);
return result;
}
- int res = appendStoreListNode(certList, length, certChainName[i], alias, storeType);
+ int res = appendStoreListNode(certList, length, certChainName[i], commonName, storeType);
if (res != CERTSVC_SUCCESS) {
LogError("Failed to append store list node.");
return result;