From 11c8c7c08ae075a245cbdd113846b6c7c502488f Mon Sep 17 00:00:00 2001 From: zhouping Date: Sun, 23 Feb 2020 16:11:42 +0800 Subject: [PATCH] =?UTF-8?q?=E6=97=A0JIRA=E4=BB=BB=E5=8A=A1=20build=20faile?= =?UTF-8?q?d?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../conn/ssl/DefaultHostnameVerifier.java | 33 ++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) 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; + } + } +}