diff --git a/components/certificate-mgt/org.wso2.carbon.certificate.mgt.cert.admin.api/src/main/java/org/wso2/carbon/certificate/mgt/cert/jaxrs/api/impl/CertificateManagementAdminServiceImpl.java b/components/certificate-mgt/org.wso2.carbon.certificate.mgt.cert.admin.api/src/main/java/org/wso2/carbon/certificate/mgt/cert/jaxrs/api/impl/CertificateManagementAdminServiceImpl.java index f3c454bda59..e0f0852787c 100644 --- a/components/certificate-mgt/org.wso2.carbon.certificate.mgt.cert.admin.api/src/main/java/org/wso2/carbon/certificate/mgt/cert/jaxrs/api/impl/CertificateManagementAdminServiceImpl.java +++ b/components/certificate-mgt/org.wso2.carbon.certificate.mgt.cert.admin.api/src/main/java/org/wso2/carbon/certificate/mgt/cert/jaxrs/api/impl/CertificateManagementAdminServiceImpl.java @@ -17,6 +17,7 @@ import org.wso2.carbon.context.PrivilegedCarbonContext; import javax.ws.rs.*; import javax.ws.rs.core.Response; +import java.security.cert.X509Certificate; import java.util.ArrayList; import java.util.List; @@ -42,8 +43,10 @@ public class CertificateManagementAdminServiceImpl implements CertificateManagem for (EnrollmentCertificate enrollmentCertificate : enrollmentCertificates) { certificate = new org.wso2.carbon.certificate.mgt.core.bean.Certificate(); certificate.setTenantId(PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId()); - certificate.setSerial(enrollmentCertificate.getSerial()); - certificate.setCertificate(certificateService.pemToX509Certificate(enrollmentCertificate.getPem())); + X509Certificate x509Certificate = certificateService + .pemToX509Certificate(enrollmentCertificate.getPem()); + certificate.setSerial(x509Certificate.getSerialNumber().toString()); + certificate.setCertificate(x509Certificate); certificates.add(certificate); } certificateService.saveCertificate(certificates); diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.certificate.create/create.hbs b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.certificate.create/create.hbs index 4d0f953422a..46e213d374e 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.certificate.create/create.hbs +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.certificate.create/create.hbs @@ -51,14 +51,6 @@ - - -
-
- -
diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.certificate.create/public/js/certificate-create.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.certificate.create/public/js/certificate-create.js index 4ccd72a11fd..6de3971b80c 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.certificate.create/public/js/certificate-create.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/cdmf.page.certificate.create/public/js/certificate-create.js @@ -92,17 +92,11 @@ $(document).ready(function () { * when a user clicks on "Add Certificate" button. */ $("button#add-certificate-btn").click(function () { - var serialNoInput = $("input#serialNo"); - var serialNo = serialNoInput.val(); - if (!serialNo) { - $(errorMsg).text("Serial Number is a required field. It cannot be empty."); - $(errorMsgWrapper).removeClass("hidden"); - } else if (!pemContent) { + if (!pemContent) { $(errorMsg).text(" .pem file must contains certificate information."); $(errorMsgWrapper).removeClass("hidden"); } else { var addCertificateFormData = {}; - addCertificateFormData.serial = serialNo; addCertificateFormData.pem = pemContent; var certificateList = []; certificateList.push(addCertificateFormData);