作者 陈刚

init

HELP.md
target/
!.mvn/wrapper/maven-wrapper.jar
!**/src/main/**
!**/src/test/**
### STS ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache
### IntelliJ IDEA ###
.idea
*.iws
*.iml
*.ipr
### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/
build/
.idea
### VS Code ###
.vscode/
/logs/
/crawler/logs
... ...
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.aukey</groupId>
<artifactId>aukey-server-parent</artifactId>
<version>1.0.0-SNAPSHOT</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.aukey.dws.ddh</groupId>
<artifactId>check-https-utils</artifactId>
<version>1.0.0</version>
<properties>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.6</version>
</dependency>
<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>okhttp</artifactId>
</dependency>
</dependencies>
</project>
... ...
package com.check;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import org.apache.commons.io.FileUtils;
import org.apache.commons.lang3.StringUtils;
import java.io.File;
import java.net.URL;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
/**
* 测试https是否可以访问
*
* @author weishaolei
*/
public class CheckHttpsUtils {
public static void main(String[] args) throws Exception {
//读取文件里的url
URL resource = CheckHttpsUtils.class.getClassLoader().getResource("url.txt");
List<String> urls = FileUtils.readLines(new File(resource.getFile()), "utf-8");
List<String> errorList = new ArrayList();
Set<String> distinctUrl = new HashSet<>(urls); //去重
OkHttpClient client = new OkHttpClient();
for (String url : distinctUrl) {
try {
//去前后空格
String s = StringUtils.trimToNull(url);
if (s == null) continue;
//将http强转为https
url = url.replace("http://", "https://");
url = url.replace("HTTP://", "https://");
//检测https的GET请求
Request request = new Request.Builder()
.url(url)
.get()
.build();
client.newCall(request).execute();
System.out.println(url + " 成功支持HTTPS");
} catch (Exception e) {
System.out.println(url + " 不支持HTTPS, 错误原因: " + e.getMessage());
errorList.add(url);
}
}
if (errorList.isEmpty()) {
System.out.println("所有域名都支持https.");
} else {
System.err.println("--------------------------------------------------------");
System.err.println("--------------- 无法访问https的所有域名如下 ----------------");
System.err.println("--------------------------------------------------------");
for (String s : errorList) {
System.err.println(s);
}
}
}
}
... ...
https://dw_gz.aukeyit.com
http://browser-interface.qa.aukeyit.com
https://eureka.qa.aukeyit.com/
\ No newline at end of file
... ...