Fix macos enrollment error due to invalid challenge token

4.x.x
Saad Sahibjan 6 years ago
parent 5962a24029
commit 2da0a6aa19

@ -49,6 +49,8 @@ import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@Path("/admin/certificates") @Path("/admin/certificates")
public class CertificateManagementAdminServiceImpl implements CertificateManagementAdminService { public class CertificateManagementAdminServiceImpl implements CertificateManagementAdminService {
@ -242,7 +244,11 @@ public class CertificateManagementAdminServiceImpl implements CertificateManagem
String challengeToken = certMgtService.extractChallengeToken(cert); String challengeToken = certMgtService.extractChallengeToken(cert);
if (challengeToken != null) { 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(); challengeToken = challengeToken.substring(challengeToken.indexOf("(") + 1).trim();
SCEPManager scepManager = CertificateMgtAPIUtils.getSCEPManagerService(); SCEPManager scepManager = CertificateMgtAPIUtils.getSCEPManagerService();

Loading…
Cancel
Save