diff --git a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/conn/ssl/DefaultHostnameVerifier.java b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/conn/ssl/DefaultHostnameVerifier.java index 0cde5ab0a..bc7792425 100644 --- a/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/conn/ssl/DefaultHostnameVerifier.java +++ b/fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/conn/ssl/DefaultHostnameVerifier.java @@ -299,4 +299,35 @@ public final class DefaultHostnameVerifier implements HostnameVerifier { static List getSubjectAltNames(final X509Certificate cert) { try { final Collection> entries = cert.getSubjectAlternativeNames(); - if (entrie \ No newline at end of file + if (entries == null) { + return Collections.emptyList(); + } + final List result = new ArrayList(); + for (List entry: entries) { + final Integer type = entry.size() >= 2 ? (Integer) entry.get(0) : null; + if (type != null) { + final String s = (String) entry.get(1); + result.add(new SubjectName(s, type)); + } + } + return result; + } catch (final CertificateParsingException ignore) { + return Collections.emptyList(); + } + } + + /* + * Normalize IPv6 or DNS name. + */ + static String normaliseAddress(final String hostname) { + if (hostname == null) { + return hostname; + } + try { + final InetAddress inetAddress = InetAddress.getByName(hostname); + return inetAddress.getHostAddress(); + } catch (final UnknownHostException unexpected) { // Should not happen, because we check for IPv6 address above + return hostname; + } + } +}