Browse Source

无JIRA任务 build failed

research/10.0
zhouping 5 years ago
parent
commit
11c8c7c08a
  1. 33
      fine-httpcomponents/http-client/httpclient/src/main/java/com/fr/third/org/apache/http/conn/ssl/DefaultHostnameVerifier.java

33
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<SubjectName> getSubjectAltNames(final X509Certificate cert) { static List<SubjectName> getSubjectAltNames(final X509Certificate cert) {
try { try {
final Collection<List<?>> entries = cert.getSubjectAlternativeNames(); final Collection<List<?>> entries = cert.getSubjectAlternativeNames();
if (entrie if (entries == null) {
return Collections.emptyList();
}
final List<SubjectName> result = new ArrayList<SubjectName>();
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;
}
}
}

Loading…
Cancel
Save