@@ -582,28 +582,7 @@ private boolean hasValidDNs(final X509Certificate[] currentX509Certs, final X509
582582 final Function <? super X509Certificate , String > formatDNString = cert -> {
583583 final String issuerDn = cert !=null && cert .getIssuerX500Principal () != null ? cert .getIssuerX500Principal ().getName () : "" ;
584584 final String subjectDn = cert !=null && cert .getSubjectX500Principal () != null ? cert .getSubjectX500Principal ().getName () : "" ;
585- String san = "" ;
586- try {
587- Collection <List <?>> altNames = cert !=null && cert .getSubjectAlternativeNames () != null ? cert .getSubjectAlternativeNames () : null ;
588- if (altNames != null ) {
589- Collection <List <?>> sans = new ArrayList <>();
590- for (List <?> altName : altNames ) {
591- Integer type = (Integer ) altName .get (0 );
592- // otherName requires parsing to string
593- if (type == 0 ) {
594- List <?> otherName = getOtherName (altName );
595- if (otherName != null ) {
596- sans .add (Arrays .asList (type , otherName ));
597- }
598- } else {
599- sans .add (altName );
600- }
601- }
602- san = sans .toString ();
603- }
604- } catch (CertificateParsingException e ) {
605- log .error ("Issue parsing SubjectAlternativeName:" , e );
606- }
585+ final String san = getSubjectAlternativeNames (cert );
607586 return String .format ("%s/%s/%s" , issuerDn , subjectDn , san );
608587 };
609588
@@ -977,6 +956,34 @@ private static void checkPath(String keystoreFilePath, String fileNameLogOnly) {
977956 }
978957 }
979958
959+ @ Override
960+ public String getSubjectAlternativeNames (X509Certificate cert ) {
961+ String san = "" ;
962+ try {
963+ Collection <List <?>> altNames = cert !=null && cert .getSubjectAlternativeNames () != null ? cert .getSubjectAlternativeNames () : null ;
964+ if (altNames != null ) {
965+ Collection <List <?>> sans = new ArrayList <>();
966+ for (List <?> altName : altNames ) {
967+ Integer type = (Integer ) altName .get (0 );
968+ // otherName requires parsing to string
969+ if (type == 0 ) {
970+ List <?> otherName = getOtherName (altName );
971+ if (otherName != null ) {
972+ sans .add (Arrays .asList (type , otherName ));
973+ }
974+ } else {
975+ sans .add (altName );
976+ }
977+ }
978+ san = sans .toString ();
979+ }
980+ } catch (CertificateParsingException e ) {
981+ log .error ("Issue parsing SubjectAlternativeName:" , e );
982+ }
983+
984+ return san ;
985+ }
986+
980987 private List <String > getOtherName (List <?> altName ) {
981988 ASN1Primitive oct = null ;
982989 try {
0 commit comments