Skip to content

Commit

Permalink
Address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
normanmaurer committed Jul 19, 2023
1 parent 08eb636 commit 4b30188
Showing 1 changed file with 10 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import java.net.Socket;
import java.security.cert.CertificateException;
import java.security.cert.X509Certificate;
import java.util.Collection;
import java.util.List;


Expand Down Expand Up @@ -100,18 +101,22 @@ private static void throwEnhancedCertificateException(X509Certificate[] chain, C
StringBuilder names = new StringBuilder(64);
for (int i = 0; i < chain.length; i++) {
X509Certificate cert = chain[i];
for (List<?> altNames : cert.getSubjectAlternativeNames()) {
// 2 is dNSName. See X509Certificate javadocs.
if (altNames.size() >= 2 && ((Integer) altNames.get(0)) == 2) {
names.append((String) altNames.get(1)).append(",");
Collection<List<?>> collection = cert.getSubjectAlternativeNames();
if (collection != null) {
for (List<?> altNames : collection) {
// 2 is dNSName. See X509Certificate javadocs.
if (altNames.size() >= 2 && ((Integer) altNames.get(0)).intValue() == 2) {
names.append((String) altNames.get(1)).append(",");
}
}
}
}
if (names.length() != 0) {
// Strip of ,
names.setLength(names.length() - 1);
throw new CertificateException(message +
" Subject alternative DNS names in the certificate chain: " + names, e);
" Subject alternative DNS names in the certificate chain of " + chain.length +
" certificate(s): " + names, e);
}
}
throw e;
Expand Down

0 comments on commit 4b30188

Please sign in to comment.