#include <openssl/bio.h>
#include <dpl/foreach.h>
-#include <dpl/log/wrt_log.h>
+#include <dpl/log/log.h>
#include <cert-svc/cinstance.h>
#include <cert-svc/ccert.h>
#define START_TRUSTED "-----BEGIN TRUSTED CERTIFICATE-----"
#define END_TRUSTED "-----END TRUSTED CERTIFICATE-----"
-#ifndef LOG_TAG
-#define LOG_TAG "CERT_SVC"
-#endif
-
using namespace ValidationCore;
namespace {
fieldId = SUBJECT_COMMONNAME;
break;
default:
- WrtLogE("Not implemented!");
+ LogError("Not implemented!");
return CERTSVC_WRONG_ARGUMENT;
}
cert_svc_cert_context_final);
if (ctx.get() == NULL) {
- WrtLogW("Error in cert_svc_cert_context_init.");
+ LogWarning("Error in cert_svc_cert_context_init.");
return CERTSVC_FAIL;
}
- WrtLogD("Match string: %s", value);
+ LogDebug("Match string : " << value);
result = cert_svc_search_certificate(ctx.get(), fieldId, const_cast<char*>(value));
- WrtLogD("Search finished!");
+ LogDebug("Search finished!");
if (CERT_SVC_ERR_NO_ERROR != result) {
- WrtLogW("Error during certificate search");
+ LogWarning("Error during certificate search");
return CERTSVC_FAIL;
}
ScopedCertCtx ctx2(cert_svc_cert_context_init(),
cert_svc_cert_context_final);
if (ctx2.get() == NULL) {
- WrtLogW("Error in cert_svc_cert_context_init.");
+ LogWarning("Error in cert_svc_cert_context_init.");
return CERTSVC_FAIL;
}
if (CERT_SVC_ERR_NO_ERROR !=
cert_svc_load_file_to_context(ctx2.get(), fileList->filename))
{
- WrtLogW("Error in cert_svc_load_file_to_context");
+ LogWarning("Error in cert_svc_load_file_to_context");
return CERTSVC_FAIL;
}
int certId = addCert(CertificatePtr(new Certificate(*(ctx2.get()->certBuf))));
xmlDocPtr doc = xmlParseFile(FINGERPRINT_LIST_PATH);
if ((doc == NULL) || (xmlDocGetRootElement(doc) == NULL))
{
- WrtLogE("Failed to prase fingerprint_list.xml");
+ LogError("Failed to prase fingerprint_list.xml");
return CERTSVC_IO_ERROR;
}
xmlNodePtr curPtr = xmlFirstElementChild(xmlDocGetRootElement(doc));
if(curPtr == NULL)
{
- WrtLogE("Can not find root");
+ LogError("Can not find root");
ret = CERTSVC_IO_ERROR;
goto out;
}
xmlAttr* attr = curPtr->properties;
if(!attr->children || !attr->children->content)
{
- WrtLogE("Failed to get fingerprints from list");
+ LogError("Failed to get fingerprints from list");
ret = CERTSVC_FAIL;
goto out;
}
xmlNodePtr FpPtr = xmlFirstElementChild(curPtr);
if(FpPtr == NULL)
{
- WrtLogE("Could not find fingerprint");
+ LogError("Could not find fingerprint");
ret = CERTSVC_FAIL;
goto out;
}
- WrtLogD("Retrieve level : %s", strLevel);
+ LogDebug("Retrieve level : " << strLevel);
while(FpPtr)
{
xmlChar *content = xmlNodeGetContent(FpPtr);
if(xmlStrcmp(content, (xmlChar*)fingerprint.c_str()) == 0)
{
- WrtLogD("fingerprint : %s are %s", content, strLevel);
+ LogDebug("fingerprint : " << content << " are " << strLevel);
if(!xmlStrcmp(strLevel, xmlPathDomainPlatform))
{
*visibility = CERTSVC_VISIBILITY_PLATFORM;
result = c_certsvc_pkcs12_load_certificates_from_store(storeType, pfxIdString.privateHandler, &certs, &ncerts);
if (result != CERTSVC_SUCCESS) {
- WrtLogE("Unable to load certificates from store.");
+ LogError("Unable to load certificates from store.");
return result;
}
Alias.privateLength = strlen(certs[i]);
result = certsvc_pkcs12_get_certificate_info_from_store(instance, storeType, Alias, &certBuffer, &certLength);
if (result != CERTSVC_SUCCESS || !certBuffer) {
- WrtLogE("Failed to get certificate buffer.");
+ LogError("Failed to get certificate buffer.");
return CERTSVC_FAIL;
}
}
if (!trailer) {
- WrtLogE("Failed the get the certificate.");
+ LogError("Failed the get the certificate.");
return CERTSVC_FAIL;
}
&size);
if (result != CERTSVC_SUCCESS) {
- WrtLogE("Error in certsvc_pkcs12_private_key_dup");
+ LogError("Error in certsvc_pkcs12_private_key_dup");
return result;
}
BIO *b = BIO_new(BIO_s_mem());
if ((int)size != BIO_write(b, buffer, size)) {
- WrtLogE("Error in BIO_write");
+ LogError("Error in BIO_write");
BIO_free_all(b);
certsvc_pkcs12_private_key_free(buffer);
return CERTSVC_FAIL;
return CERTSVC_SUCCESS;
}
- WrtLogE("Result is null. Openssl REASON code is: %d", ERR_GET_REASON(ERR_peek_last_error()));
+ LogError("Result is null. Openssl REASON code is : " << ERR_GET_REASON(ERR_peek_last_error()));
return CERTSVC_FAIL;
}
return impl(certificate.privateInstance)->getVisibility(certificate, visibility);
} catch (...)
{
- WrtLogE("exception occur");
+ LogError("exception occur");
}
return CERTSVC_FAIL;
}
try {
result = c_certsvc_pkcs12_get_certificate_buffer_from_store(storeType, gname, &certBuffer, &length);
if (result != CERTSVC_SUCCESS) {
- WrtLogE("Failed to get certificate buffer from store.");
+ LogError("Failed to get certificate buffer from store.");
return result;
}
pBio = BIO_new(BIO_s_mem());
if (pBio == NULL) {
- WrtLogE("Failed to allocate memory.");
+ LogError("Failed to allocate memory.");
result = CERTSVC_BAD_ALLOC;
}
length = BIO_write(pBio, (const void*) certBuffer, length);
if (length < 1) {
- WrtLogE("Failed to load cert into bio.");
+ LogError("Failed to load cert into bio.");
result = CERTSVC_BAD_ALLOC;
}
fileName.append(CERTSVC_PKCS12_STORAGE_DIR);
fileName.append(gname);
if (!(fp_write = fopen(fileName.c_str(), "w"))) {
- WrtLogE("Failed to open the file for writing, [%s].", fileName.c_str());
+ LogError("Failed to open the file for writing, [" << fileName << "].");
result = CERTSVC_FAIL;
goto error;
}
if (fwrite(certBuffer, sizeof(char), (size_t)length, fp_write) != (size_t)length) {
- WrtLogE("Fail to write certificate.");
+ LogError("Fail to write certificate.");
result = CERTSVC_FAIL;
goto error;
}
fclose(fp_write);
result = certsvc_certificate_new_from_file(instance, fileName.c_str(), certificate);
if (result != CERTSVC_SUCCESS) {
- WrtLogE("Failed to construct certificate from buffer.");
+ LogError("Failed to construct certificate from buffer.");
goto error;
}
unlink(fileName.c_str());
int *is_unique)
{
if (pfxIdString.privateHandler == NULL || pfxIdString.privateLength<=0) {
- WrtLogE("Invalid input parameter.");
+ LogError("Invalid input parameter.");
return CERTSVC_WRONG_ARGUMENT;
}
try {
if (!impl(instance)->checkValidStoreType(storeType)) {
- WrtLogE("Invalid input parameter.");
+ LogError("Invalid input parameter.");
return CERTSVC_INVALID_STORE_TYPE;
}
CertSvcStoreCertList** certList)
{
if (*certList == NULL) {
- WrtLogE("Invalid input parameter.");
+ LogError("Invalid input parameter.");
return CERTSVC_WRONG_ARGUMENT;
}
int* length)
{
if (*certList != NULL) {
- WrtLogE("Invalid input parameter.");
+ LogError("Invalid input parameter.");
return CERTSVC_WRONG_ARGUMENT;
}
try {
if (!impl(instance)->checkValidStoreType(storeType)) {
- WrtLogE("Invalid input parameter.");
+ LogError("Invalid input parameter.");
return CERTSVC_INVALID_STORE_TYPE;
}
int* length)
{
if (*certList != NULL) {
- WrtLogE("Invalid input parameter.");
+ LogError("Invalid input parameter.");
return CERTSVC_WRONG_ARGUMENT;
}
try {
if (!impl(instance)->checkValidStoreType(storeType)) {
- WrtLogE("Invalid input parameter.");
+ LogError("Invalid input parameter.");
return CERTSVC_INVALID_STORE_TYPE;
}
int* length)
{
if (*certList != NULL) {
- WrtLogE("Invalid input parameter.");
+ LogError("Invalid input parameter.");
return CERTSVC_WRONG_ARGUMENT;
}
try {
if (!impl(instance)->checkValidStoreType(storeType)) {
- WrtLogE("Invalid input parameter.");
+ LogError("Invalid input parameter.");
return CERTSVC_INVALID_STORE_TYPE;
}
size_t* certSize)
{
if (*certBuffer != NULL) {
- WrtLogE("Invalid input parameter.");
+ LogError("Invalid input parameter.");
return CERTSVC_WRONG_ARGUMENT;
}
try {
if (!impl(instance)->checkValidStoreType(storeType)) {
- WrtLogE("Invalid input parameter.");
+ LogError("Invalid input parameter.");
return CERTSVC_INVALID_STORE_TYPE;
}
{
try {
if (!impl(instance)->checkValidStoreType(storeType)) {
- WrtLogE("Invalid input parameter.");
+ LogError("Invalid input parameter.");
return CERTSVC_INVALID_STORE_TYPE;
}
return impl(instance)->pkcsDeleteCertFromStore(storeType, gname);
try {
if (path.privateHandler != NULL) {
if (!impl(instance)->checkValidStoreType(storeType)) {
- WrtLogE("Invalid input parameter.");
+ LogError("Invalid input parameter.");
return CERTSVC_INVALID_STORE_TYPE;
}
return impl(instance)->pkcsImportToStore(storeType, path, password, pfxIdString);
char **alias)
{
if (gname.privateHandler == NULL || gname.privateLength<=0) {
- WrtLogE("Invalid input parameter.");
+ LogError("Invalid input parameter.");
return CERTSVC_WRONG_ARGUMENT;
}
try {
if (!impl(instance)->checkValidStoreType(storeType)) {
- WrtLogE("Invalid input parameter.");
+ LogError("Invalid input parameter.");
return CERTSVC_INVALID_STORE_TYPE;
}
return impl(instance)->pkcsGetAliasNameForCertInStore(storeType, gname, alias);
{
try {
if (!impl(instance)->checkValidStoreType(storeType)) {
- WrtLogE("Invalid input parameter.");
+ LogError("Invalid input parameter.");
return CERTSVC_INVALID_STORE_TYPE;
}
return impl(instance)->pkcsSetCertStatusToStore(storeType, is_root_app, gname, status);
{
try {
if (!impl(instance)->checkValidStoreType(storeType)) {
- WrtLogE("Invalid input parameter.");
+ LogError("Invalid input parameter.");
return CERTSVC_INVALID_STORE_TYPE;
}
return impl(instance)->pkcsGetCertStatusFromStore(storeType, gname, status);
{
try {
if (!impl(instance)->checkValidStoreType(storeType)) {
- WrtLogE("Invalid input parameter.");
+ LogError("Invalid input parameter.");
return CERTSVC_INVALID_STORE_TYPE;
}
return impl(instance)->getCertFromStore(instance, storeType, gname, certificate);
{
try {
if (!impl(instance)->checkValidStoreType(storeType)) {
- WrtLogE("Invalid input parameter.");
+ LogError("Invalid input parameter.");
return CERTSVC_INVALID_STORE_TYPE;
}
return impl(instance)->getPkcsCertificateListFromStore(instance, storeType, pfxIdString, certificateList);
{
try {
if (!impl(instance)->checkValidStoreType(storeType)) {
- WrtLogE("Invalid input parameter.");
+ LogError("Invalid input parameter.");
return CERTSVC_INVALID_STORE_TYPE;
}
return impl(instance)->getPkcsPrivateKeyFromStore(storeType, gname, certBuffer, certSize);
int result = certsvc_pkcs12_private_key_dup_from_store(instance, storeType, gname, &buffer, &size);
if (result != CERTSVC_SUCCESS) {
- WrtLogE("Error in certsvc_pkcs12_private_key_dup");
+ LogError("Error in certsvc_pkcs12_private_key_dup");
return result;
}
BIO *b = BIO_new(BIO_s_mem());
if ((int)size != BIO_write(b, buffer, size)) {
- WrtLogE("Error in BIO_write");
+ LogError("Error in BIO_write");
BIO_free_all(b);
certsvc_pkcs12_private_key_free(buffer);
return CERTSVC_FAIL;
if (*pkey)
return CERTSVC_SUCCESS;
- WrtLogE("Result is null. Openssl REASON code is: %d", ERR_GET_REASON(ERR_peek_last_error()));
+ LogError("Result is null. Openssl REASON code is : " << ERR_GET_REASON(ERR_peek_last_error()));
return CERTSVC_FAIL;
}