Scan+score

This commit is contained in:
M66B
2021-08-16 21:14:25 +02:00
parent 9a09474c3a
commit a215bcf6e8
3 changed files with 76 additions and 64 deletions

View File

@@ -41,7 +41,6 @@ import org.json.JSONException;
import org.json.JSONObject;
import java.io.ByteArrayInputStream;
import java.net.InetAddress;
import java.security.NoSuchAlgorithmException;
import java.security.cert.CertificateEncodingException;
import java.security.cert.CertificateException;
@@ -217,31 +216,6 @@ public class EntityCertificate {
return result;
}
static String getSimilarDnsName(X509Certificate certificate, @NonNull String host) {
if (certificate == null)
return null;
try {
InetAddress haddr = InetAddress.getByName(host);
List<String> names = getDnsNames(certificate);
for (String _name : names)
try {
String name = (_name.startsWith("*.") ? _name.substring(2) : _name);
InetAddress naddr = InetAddress.getByName(name);
Log.i("host=" + host + " name=" + _name + "" +
" haddr=" + haddr + " naddr=" + naddr);
if (haddr.equals(naddr))
return name;
} catch (Throwable ex) {
Log.w(ex);
}
} catch (Throwable ex) {
Log.w(ex);
}
return null;
}
static boolean matches(String server, List<String> names) {
for (String name : names)
if (matches(server, name)) {