cucumber - 放心:忽略证书错误
问题描述
我从服务器取回的证书有错误:
javax.net.ssl.SSLProtocolException:X.509 证书不完整:SubjectAlternativeName 扩展必须在主题字段为空时标记为关键
我发现使用 RelaxedHTTPSValidation 应该可以忽略证书错误。
所以我试着像这样使用它:
@When("^Get All Applications Request Executed$")
public void getAllApplicationsRequestExecuted() {
response =
given()
.relaxedHTTPSValidation()
.log().all()
.spec(testContext().getRequestSpec())
.when()
.get("application/api/virtual-services/") //Send the request along with the resource
.then()
.extract()
.response();
testContext().setResponse(response);
}
另外,我添加了这个@Before 钩子:
@Before
public void setUseRelaxedHTTPSValidation(){
RestAssured.useRelaxedHTTPSValidation();
}
但我看不出有什么变化。
解决方案
尝试通过这样的配置使用:
@When("^Get All Applications Request Executed$")
public void getAllApplicationsRequestExecuted() {
given()
.config(RestAssured.config().sslConfig(new SSLConfig().allowAllHostnames()))
.log().all()
.spec(testContext().getRequestSpec())
.when()
.get("application/api/virtual-services/") //Send the request along with the resource
.then()
.extract()
.response();
testContext().setResponse(response);
}
推荐阅读
- visual-studio - Xamarin.Forms Android 应用程序在启动时崩溃(仅在发布版本中)
- javascript - 如何使用 React 应用程序将一个 asp.net 核心控制器操作视图访问到 iframe 中?
- java - Angularjs将文件多部分FormData中的空值传递给Spring MVC
- javascript - Python Flask:使用 JQuery 将变量数据发送到同一 html 页面上的 textarea
- android - 找不到 com.android.tools.build:gradle:5.6
- java - 获取字符串值的最大值
- node.js - 如何在nodejs应用程序的swagger-ui中指定多个基本路径
- android - 斑马扫描仪 LI4278 有时会在代码中间输入 enter
- java - 如果列表为空/null,则 IN 子句选择所有元素
- html - 从所有类型的 li 和 ul 中删除黑点