From e98674f9b95b89c3a37f1c1157e12d9c0347d32f Mon Sep 17 00:00:00 2001 From: inoshperera Date: Fri, 10 May 2019 07:57:39 +0530 Subject: [PATCH 1/2] init commit for MacOS --- .../jaxrs/api/impl/CertificateManagementAdminServiceImpl.java | 1 + 1 file changed, 1 insertion(+) 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 5957b1b8cf..c1cb5c7197 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 @@ -242,6 +242,7 @@ public class CertificateManagementAdminServiceImpl implements CertificateManagem String challengeToken = certMgtService.extractChallengeToken(cert); if (challengeToken != null) { + challengeToken = challengeToken.replace("\u0004&\u0013$",""); challengeToken = challengeToken.substring(challengeToken.indexOf("(") + 1).trim(); SCEPManager scepManager = CertificateMgtAPIUtils.getSCEPManagerService(); From 2da0a6aa1921bbf9f52119bd834ffec2b8e254c3 Mon Sep 17 00:00:00 2001 From: Saad Sahibjan Date: Mon, 20 May 2019 11:54:13 +0530 Subject: [PATCH 2/2] Fix macos enrollment error due to invalid challenge token --- .../api/impl/CertificateManagementAdminServiceImpl.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) 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 c1cb5c7197..697aadc1a8 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 @@ -49,6 +49,8 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.regex.Matcher; +import java.util.regex.Pattern; @Path("/admin/certificates") public class CertificateManagementAdminServiceImpl implements CertificateManagementAdminService { @@ -242,7 +244,11 @@ public class CertificateManagementAdminServiceImpl implements CertificateManagem String challengeToken = certMgtService.extractChallengeToken(cert); if (challengeToken != null) { - challengeToken = challengeToken.replace("\u0004&\u0013$",""); + Pattern regexPattern = Pattern.compile("[a-zA-Z0-9][a-zA-Z0-9-]+$"); + Matcher regexMatcher = regexPattern.matcher(challengeToken); + if (regexMatcher.find()) { + challengeToken = regexMatcher.group(); + } challengeToken = challengeToken.substring(challengeToken.indexOf("(") + 1).trim(); SCEPManager scepManager = CertificateMgtAPIUtils.getSCEPManagerService();