Skip to content

Commit

Permalink
backport: square#6483
Browse files Browse the repository at this point in the history
  • Loading branch information
suxinglee committed Jan 30, 2024
1 parent ad97bd3 commit a4a853d
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import javax.net.ssl.SSLException;
import javax.net.ssl.SSLSession;

import static okhttp3.internal.Util.canonicalizeHost;
import static okhttp3.internal.Util.verifyAsIpAddress;

/**
Expand Down Expand Up @@ -60,9 +61,10 @@ public boolean verify(String host, X509Certificate certificate) {

/** Returns true if {@code certificate} matches {@code ipAddress}. */
private boolean verifyIpAddress(String ipAddress, X509Certificate certificate) {
String canonicalIpAddress = canonicalizeHost(ipAddress);
List<String> altNames = getSubjectAltNames(certificate, ALT_IPA_NAME);
for (int i = 0, size = altNames.size(); i < size; i++) {
if (ipAddress.equalsIgnoreCase(altNames.get(i))) {
if (canonicalIpAddress.equals(canonicalizeHost(altNames.get(i)))) {
return true;
}
}
Expand Down

0 comments on commit a4a853d

Please sign in to comment.