Skip to content

Commit

Permalink
启动时证书安装检测bug修复
Browse files Browse the repository at this point in the history
  • Loading branch information
monkeyWie committed Mar 5, 2018
1 parent f8c4525 commit d8ba200
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
11 changes: 9 additions & 2 deletions common/src/main/java/lee/study/down/util/OsUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -257,10 +257,10 @@ public static boolean existsCert(String name, String sha1) throws IOException {
public static boolean existsCert(String name) throws IOException {
if (OsUtil.isWindows()) {
if (isAdmin()
&& findCertList(name, true).indexOf("=====") != -1) {
&& existsWindowsCert(name, true)) {
return true;
} else {
if (findCertList(name, false).indexOf("=====") != -1) {
if (existsWindowsCert(name, false)) {
return true;
}
}
Expand All @@ -275,6 +275,13 @@ && findCertList(name, true).indexOf("=====") != -1) {
return false;
}

/**
* 判断证书是否存在
*/
public static boolean existsWindowsCert(String name, boolean isAdmin) throws IOException {
return findCertList(name, isAdmin).indexOf("=====") != -1;
}

/**
* 安装证书
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ private void afterTrayInit() {
.getEncoded());
if (OsUtil.existsCert(HttpDownConstant.CA_SUBJECT)) {
//重新生成卸载之前的证书
if (OsUtil.isWindows() && !OsUtil.isAdmin()) { //admin权限静默卸载
if (OsUtil.isWindows() && OsUtil.existsWindowsCert(HttpDownConstant.CA_SUBJECT,false)) { //admin权限静默卸载
showMsg("检测到系统存在旧的证书,请按确定再根据引导进行删除");
}
OsUtil.uninstallCert(HttpDownConstant.CA_SUBJECT);
Expand Down

0 comments on commit d8ba200

Please sign in to comment.