+int CKMLogic::readCertificateHelper(
+ const Credentials &cred,
+ const LabelNameVector &labelNameVector,
+ CertificateImplVector &certVector)
+{
+ DB::Row row;
+ for (auto &i: labelNameVector) {
+ int ec = readDataHelper(false, cred, DataType::CERTIFICATE, i.second, i.first, Password(), row);
+ if (ec != CKM_API_SUCCESS)
+ return ec;
+ certVector.push_back(CertificateImpl(row.data, DataFormat::FORM_DER));
+
+ // try to read chain certificates (if present)
+ DB::RowVector rawCaChain;
+ ec = readDataHelper(false, cred, DataType::DB_CHAIN_FIRST, i.second, i.first, CKM::Password(), rawCaChain);
+ if(ec != CKM_API_SUCCESS && ec != CKM_API_ERROR_DB_ALIAS_UNKNOWN)
+ return ec;
+ for(auto &rawCaCert : rawCaChain)
+ certVector.push_back(CertificateImpl(rawCaCert.data, DataFormat::FORM_DER));
+ }
+ return CKM_API_SUCCESS;
+}
+
+int CKMLogic::getCertificateChainHelper(
+ const CertificateImpl &cert,
+ const RawBufferVector &untrustedCertificates,
+ const RawBufferVector &trustedCertificates,
+ bool useTrustedSystemCertificates,
+ RawBufferVector &chainRawVector)
+{
+ CertificateImplVector untrustedCertVector;
+ CertificateImplVector trustedCertVector;
+ CertificateImplVector chainVector;