Skip to content

Commit bb6c092

Browse files
committed
fix: update SSL verification default to true for improved development experience
1 parent 0fc21dc commit bb6c092

4 files changed

Lines changed: 29 additions & 3 deletions

File tree

easy-postman-app/src/main/java/com/laker/postman/model/PreparedRequest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public class PreparedRequest {
2424
public boolean isMultipart;
2525
public boolean followRedirects = true; // 默认自动重定向
2626
public boolean cookieJarEnabled = true; // 默认启用 Cookie Jar
27-
public boolean sslVerificationEnabled = true; // 默认启用 SSL 校验
27+
public boolean sslVerificationEnabled = false; // 默认禁用 SSL 校验
2828
public String httpVersion = HttpRequestItem.HTTP_VERSION_AUTO; // HTTP 协议偏好
2929
public int requestTimeoutMs = 0; // 0 表示不超时
3030

easy-postman-app/src/main/java/com/laker/postman/service/HistoryPersistenceService.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -405,7 +405,7 @@ private RequestHistoryItem convertFromJson(JSONObject jsonItem) {
405405
request.followRedirects = requestJson.getBool("followRedirects", true);
406406
request.isMultipart = requestJson.getBool("isMultipart", false);
407407
request.cookieJarEnabled = requestJson.getBool("cookieJarEnabled", true);
408-
request.sslVerificationEnabled = requestJson.getBool("sslVerificationEnabled", true);
408+
request.sslVerificationEnabled = requestJson.getBool("sslVerificationEnabled", false);
409409
request.httpVersion = requestJson.getStr("httpVersion");
410410
request.requestTimeoutMs = requestJson.getInt("requestTimeoutMs", 0);
411411
request.collectBasicInfo = requestJson.getBool("collectBasicInfo", true);

easy-postman-app/src/main/java/com/laker/postman/service/setting/SettingManager.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -925,7 +925,7 @@ public static boolean isProxySslVerificationDisabled() {
925925
if (val != null) {
926926
return Boolean.parseBoolean(val);
927927
}
928-
return false; // 默认启用 SSL 验证
928+
return true; // 默认禁用代理 SSL 验证,避免代理环境阻断请求
929929
}
930930

931931
public static void setProxySslVerificationDisabled(boolean disabled) {

easy-postman-app/src/test/java/com/laker/postman/service/setting/SettingManagerTrustedCertificateTest.java

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,15 @@
22

33
import cn.hutool.json.JSONUtil;
44
import com.laker.postman.model.TrustedCertificateEntry;
5+
import com.laker.postman.model.PreparedRequest;
56
import org.testng.annotations.Test;
67

78
import java.lang.reflect.Field;
89
import java.util.List;
910
import java.util.Properties;
1011

1112
import static org.testng.Assert.assertEquals;
13+
import static org.testng.Assert.assertFalse;
1214
import static org.testng.Assert.assertTrue;
1315

1416
public class SettingManagerTrustedCertificateTest {
@@ -64,6 +66,30 @@ public void shouldPersistTrustedCertificateEntriesAsJsonList() throws Exception
6466
}
6567
}
6668

69+
@Test
70+
public void shouldDisableRequestAndProxySslVerificationByDefaultWhenUnset() throws Exception {
71+
Properties props = getSettingsProperties();
72+
Properties backup = new Properties();
73+
backup.putAll(props);
74+
75+
try {
76+
props.clear();
77+
78+
assertTrue(SettingManager.isRequestSslVerificationDisabled());
79+
assertTrue(SettingManager.isProxySslVerificationDisabled());
80+
} finally {
81+
props.clear();
82+
props.putAll(backup);
83+
}
84+
}
85+
86+
@Test
87+
public void preparedRequestShouldDefaultToLenientSslVerification() {
88+
PreparedRequest request = new PreparedRequest();
89+
90+
assertFalse(request.sslVerificationEnabled);
91+
}
92+
6793
private static Properties getSettingsProperties() throws Exception {
6894
Field propsField = SettingManager.class.getDeclaredField("props");
6995
propsField.setAccessible(true);

0 commit comments

Comments
 (0)