Commit 7fde94de authored by Oliver Sander's avatar Oliver Sander Committed by Albert Astals Cid

Make CertificateInfo a std::unique_ptr

parent 8943f7de
......@@ -122,7 +122,7 @@ static GooString SECItemToGooString(const SECItem &secItem)
return GooString((const char *)secItem.data, secItem.len);
}
X509CertificateInfo *SignatureHandler::getCertificateInfo() const
std::unique_ptr<X509CertificateInfo> SignatureHandler::getCertificateInfo() const
{
if (!CMSSignerInfo)
return nullptr;
......@@ -131,7 +131,7 @@ X509CertificateInfo *SignatureHandler::getCertificateInfo() const
if (!cert)
return nullptr;
X509CertificateInfo *certInfo = new X509CertificateInfo;
auto certInfo = std::make_unique<X509CertificateInfo>();
certInfo->setVersion(DER_GetInteger(&cert->version) + 1);
certInfo->setSerialNumber(SECItemToGooString(cert->serialNumber));
......
......@@ -47,7 +47,7 @@ public:
NSSCMSVerificationStatus validateSignature();
// Use -1 as validation_time for now
SECErrorCodes validateCertificate(time_t validation_time);
X509CertificateInfo *getCertificateInfo() const;
std::unique_ptr<X509CertificateInfo> getCertificateInfo() const;
//Translate NSS error codes
static SignatureValidationStatus NSS_SigTranslate(NSSCMSVerificationStatus nss_code);
......
......@@ -63,7 +63,6 @@ SignatureInfo::~SignatureInfo()
free(reason);
free(signer_name);
free(subject_dn);
delete cert_info;
}
/* GETTERS */
......@@ -110,7 +109,7 @@ time_t SignatureInfo::getSigningTime()
const X509CertificateInfo *SignatureInfo::getCertificateInfo() const
{
return cert_info;
return cert_info.get();
}
/* SETTERS */
......@@ -159,8 +158,7 @@ void SignatureInfo::setSigningTime(time_t signingTime)
signing_time = signingTime;
}
void SignatureInfo::setCertificateInfo(X509CertificateInfo *certInfo)
void SignatureInfo::setCertificateInfo(std::unique_ptr<X509CertificateInfo> certInfo)
{
delete cert_info;
cert_info = certInfo;
cert_info = std::move(certInfo);
}
......@@ -16,6 +16,7 @@
#ifndef SIGNATUREINFO_H
#define SIGNATUREINFO_H
#include <memory>
#include <time.h>
enum SignatureValidationStatus
......@@ -70,7 +71,7 @@ public:
void setHashAlgorithm(int);
void setSigningTime(time_t);
void setSubFilterSupport(bool isSupported) { sig_subfilter_supported = isSupported; }
void setCertificateInfo(X509CertificateInfo *);
void setCertificateInfo(std::unique_ptr<X509CertificateInfo>);
private:
SignatureInfo(const SignatureInfo &);
......@@ -78,7 +79,7 @@ private:
SignatureValidationStatus sig_status;
CertificateValidationStatus cert_status;
X509CertificateInfo *cert_info;
std::unique_ptr<X509CertificateInfo> cert_info;
char *signer_name;
char *subject_dn;
char *location;
......
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