fix(接口测试): 修复无效证书初始化问题
Signed-off-by: fit2-zhao <yong.zhao@fit2cloud.com>
This commit is contained in:
parent
ac0cc2c4a2
commit
1268b1f8fc
|
@ -27,11 +27,6 @@ import org.apache.jorphan.util.JMeterStopTestException;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.FileInputStream;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InputStream;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Configure Keystore
|
* Configure Keystore
|
||||||
*/
|
*/
|
||||||
|
@ -105,12 +100,6 @@ public class KeystoreConfig extends ConfigTestElement implements TestBean, TestS
|
||||||
// 加载认证文件
|
// 加载认证文件
|
||||||
String path = this.getPropertyAsString("MS-KEYSTORE-FILE-PATH");
|
String path = this.getPropertyAsString("MS-KEYSTORE-FILE-PATH");
|
||||||
String password = this.getPropertyAsString("MS-KEYSTORE-FILE-PASSWORD");
|
String password = this.getPropertyAsString("MS-KEYSTORE-FILE-PASSWORD");
|
||||||
InputStream in = null;
|
|
||||||
try {
|
|
||||||
in = new FileInputStream(new File(path));
|
|
||||||
} catch (IOException e) {
|
|
||||||
log.error(e.getMessage());
|
|
||||||
}
|
|
||||||
// 获取请求上的资源ID
|
// 获取请求上的资源ID
|
||||||
String resourceId = this.getPropertyAsString("MS-RESOURCE-ID");
|
String resourceId = this.getPropertyAsString("MS-RESOURCE-ID");
|
||||||
if (StringUtils.isNotBlank(resourceId)) {
|
if (StringUtils.isNotBlank(resourceId)) {
|
||||||
|
@ -124,11 +113,6 @@ public class KeystoreConfig extends ConfigTestElement implements TestBean, TestS
|
||||||
SSLManager.keyMap.put(resourceId, dto);
|
SSLManager.keyMap.put(resourceId, dto);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*SSLManager.getInstance().configureKeystore(Boolean.parseBoolean(preload),
|
|
||||||
startIndexAsInt,
|
|
||||||
endIndexAsInt,
|
|
||||||
clientCertAliasVarName, in, password);*/
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -367,9 +367,6 @@ public abstract class SSLManager {
|
||||||
* @return the singleton {@link SSLManager}
|
* @return the singleton {@link SSLManager}
|
||||||
*/
|
*/
|
||||||
public static synchronized SSLManager getInstance() {
|
public static synchronized SSLManager getInstance() {
|
||||||
if (null == SSLManager.manager) {
|
|
||||||
SSLManager.manager = new JsseSSLManager(null);
|
|
||||||
}
|
|
||||||
try {
|
try {
|
||||||
// 重新加载认证文件
|
// 重新加载认证文件
|
||||||
JMeterContext threadContext = JMeterContextService.getContext();
|
JMeterContext threadContext = JMeterContextService.getContext();
|
||||||
|
@ -381,16 +378,22 @@ public abstract class SSLManager {
|
||||||
SSLManager.manager = new JsseSSLManager(null);
|
SSLManager.manager = new JsseSSLManager(null);
|
||||||
SSLManager.manager.keyStore = null;
|
SSLManager.manager.keyStore = null;
|
||||||
// 加载认证文件
|
// 加载认证文件
|
||||||
InputStream in = new FileInputStream(new File(dto.getPath()));
|
try (InputStream in = new FileInputStream(new File(dto.getPath()))) {
|
||||||
SSLManager.manager.configureKeystore(Boolean.parseBoolean(dto.getPreload()), dto.getStartIndex(),
|
SSLManager.manager.configureKeystore(Boolean.parseBoolean(dto.getPreload()), dto.getStartIndex(),
|
||||||
dto.getEndIndex(), dto.getClientCertAliasVarName(), in, dto.getPwd());
|
dto.getEndIndex(), dto.getClientCertAliasVarName(), in, dto.getPwd());
|
||||||
log.info("加载认证文件完成 {}", resourceId);
|
log.info("加载认证文件完成 {}", resourceId);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("证书处理失败{}", e.getMessage());
|
log.error("证书处理失败{}", e.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 初始化证书对象
|
||||||
|
if (null == SSLManager.manager) {
|
||||||
|
SSLManager.manager = new JsseSSLManager(null);
|
||||||
|
}
|
||||||
|
|
||||||
return SSLManager.manager;
|
return SSLManager.manager;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue