diff --git a/core/src/com/cloud/certificate/CertificateVO.java b/core/src/com/cloud/certificate/CertificateVO.java
new file mode 100644
index 00000000000..fa63d030b4d
--- /dev/null
+++ b/core/src/com/cloud/certificate/CertificateVO.java
@@ -0,0 +1,56 @@
+/**
+ * Copyright (C) 2010 Cloud.com, Inc. All rights reserved.
+ *
+ * This software is licensed under the GNU General Public License v3 or later.
+ *
+ * It is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or any later version.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ *
+ */
+package com.cloud.certificate;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.Table;
+
+@Entity
+@Table(name="certificate")
+public class CertificateVO {
+
+ public CertificateVO(String cert)
+ {
+ this.certificate = cert;
+ }
+
+ @Id
+ @GeneratedValue(strategy=GenerationType.IDENTITY)
+ @Column(name="id")
+ private Long id = null;
+
+ @Column(name="certificate")
+ private String certificate;
+
+ public CertificateVO() {}
+
+ public Long getId() {
+ return id;
+ }
+
+ public String getCertificate() {
+ return certificate;
+ }
+ public void setCertificate(String certificate) {
+ this.certificate = certificate;
+ }
+}
diff --git a/core/src/com/cloud/certificate/dao/CertificateDao.java b/core/src/com/cloud/certificate/dao/CertificateDao.java
new file mode 100644
index 00000000000..9da10b49fef
--- /dev/null
+++ b/core/src/com/cloud/certificate/dao/CertificateDao.java
@@ -0,0 +1,26 @@
+/**
+ * Copyright (C) 2010 Cloud.com, Inc. All rights reserved.
+ *
+ * This software is licensed under the GNU General Public License v3 or later.
+ *
+ * It is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or any later version.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ *
+ */
+
+package com.cloud.certificate.dao;
+
+import com.cloud.certificate.CertificateVO;
+import com.cloud.utils.db.GenericDao;
+
+public interface CertificateDao extends GenericDao {
+ public boolean persistCustomCertToDb(String certPath);
+}
diff --git a/core/src/com/cloud/certificate/dao/CertificateDaoImpl.java b/core/src/com/cloud/certificate/dao/CertificateDaoImpl.java
new file mode 100644
index 00000000000..209c30591a6
--- /dev/null
+++ b/core/src/com/cloud/certificate/dao/CertificateDaoImpl.java
@@ -0,0 +1,51 @@
+package com.cloud.certificate.dao;
+
+import java.io.BufferedInputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+
+import javax.ejb.Local;
+
+import org.apache.log4j.Logger;
+
+import com.cloud.certificate.CertificateVO;
+import com.cloud.utils.db.DB;
+import com.cloud.utils.db.GenericDaoBase;
+
+@Local(value={CertificateDao.class}) @DB(txn=false)
+public class CertificateDaoImpl extends GenericDaoBase implements CertificateDao {
+
+ private static final Logger s_logger = Logger.getLogger(CertificateDaoImpl.class);
+
+ @Override
+ public boolean persistCustomCertToDb(String certPath){
+
+ String certStr = null;
+ byte[] buffer = new byte[(int) new File(certPath).length()];
+ BufferedInputStream f = null;
+ try
+ {
+ f = new BufferedInputStream(new FileInputStream(certPath));
+ f.read(buffer);
+ } catch (FileNotFoundException e) {
+ s_logger.warn("Unable to read the certificate: "+e);
+ return false;
+ } catch (IOException e) {
+ s_logger.warn("Unable to read the certificate: "+e);
+ return false;
+ }
+ finally
+ {
+ if (f != null)
+ try { f.close(); } catch (IOException ignored) { }
+ }
+ certStr = new String(buffer);
+
+ CertificateVO certRec = new CertificateVO(certStr);
+ this.persist(certRec);
+
+ return true;
+ }
+}