#include <dpl/log/log.h>
+#include <generic-key.h>
#include <certificate-impl.h>
#include <base64.h>
return m_x509 == NULL;
}
+GenericKey::EvpShPtr CertificateImpl::getEvpShPtr() const {
+ return GenericKey::EvpShPtr(X509_get_pubkey(m_x509), EVP_PKEY_free);
+}
+
+GenericKey CertificateImpl::getGenericKey() const {
+ GenericKey::EvpShPtr evp(X509_get_pubkey(m_x509), EVP_PKEY_free);
+ if (EVP_PKEY_type(evp->type) == EVP_PKEY_RSA)
+ return GenericKey(evp, KeyType::KEY_RSA_PUBLIC);
+ if (EVP_PKEY_type(evp->type) == EVP_PKEY_EC)
+ return GenericKey(evp, KeyType::KEY_ECDSA_PUBLIC);
+ LogError("Unsupported key type in certificate.");
+ return GenericKey();
+}
+
CertificateImpl::~CertificateImpl() {
LogDebug("free cert start ptr: " << (void*)m_x509);
X509_free(m_x509);
#include <vector>
#include <ckm/ckm-type.h>
+#include <generic-key.h>
+
extern "C" {
struct x509_st;
typedef struct x509_st X509;
RawBuffer getDER() const;
bool empty() const;
+ GenericKey::EvpShPtr getEvpShPtr() const;
+ GenericKey getGenericKey() const;
+
X509* getX509() const;
virtual ~CertificateImpl();