private static String getCommonName(String subject) {
        Pattern pattern = Pattern.compile("CN=(.*?),");
        Matcher matcher = pattern.matcher(subject);

        if (matcher.find() && matcher.group(1) != "")
            return matcher.group(1);
        return subject;
    }
Get CommonName from SubjectDN.
If regex capture is failed, return inputted SubjectDN.
@param subject: SubjectDN
@return cn or subject
src/main/java/core/packetproxy/model/ClientCertificate.java