From 801117037924f309ed8e823b8d38b7ddca27a481 Mon Sep 17 00:00:00 2001 From: Pahansith Gunathilake Date: Wed, 26 Jul 2023 15:24:05 +0000 Subject: [PATCH] Fix issue in tenant id not append to certificate subject (#188) Co-authored-by: Pahansith Reviewed-on: https://repository.entgra.net/community/device-mgt-core/pulls/188 --- .../certificate/mgt/core/impl/CertificateGenerator.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/impl/CertificateGenerator.java b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/impl/CertificateGenerator.java index 328c2fcbfb..4dfe921787 100755 --- a/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/impl/CertificateGenerator.java +++ b/components/certificate-mgt/io.entgra.device.mgt.core.certificate.mgt.core/src/main/java/io/entgra/device/mgt/core/certificate/mgt/core/impl/CertificateGenerator.java @@ -847,8 +847,9 @@ public class CertificateGenerator { X500Name issuerName = new X500Name(subjectDn); String commonName = certificationRequest.getSubject().getRDNs(BCStyle.CN)[0].getFirst() .getValue().toString(); - X500Name subjectName = new X500Name("O=" + commonName + "O=AndroidDevice,CN=" + - serialNumber); + int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(); + X500Name subjectName = new X500Name("O=" + commonName + " ,CN=" + + serialNumber + ", OU=tenant_" + tenantId); Date startDate = new Date(System.currentTimeMillis()); Date endDate = new Date(System.currentTimeMillis() + TimeUnit.DAYS.toMillis(365 * 100)); @@ -869,7 +870,7 @@ public class CertificateGenerator { io.entgra.device.mgt.core.certificate.mgt.core.bean.Certificate certificate = new io.entgra.device.mgt.core.certificate.mgt.core.bean.Certificate(); List certificates = new ArrayList<>(); - certificate.setTenantId(PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId()); + certificate.setTenantId(tenantId); certificate.setCertificate(issuedCert); certificates.add(certificate); saveCertInKeyStore(certificates);