【问题标题】:Rest Assured: ignoring certificate errors放心:忽略证书错误
【发布时间】:2019-11-05 12:01:13
【问题描述】:

我从服务器取回的证书有错误:

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();
}

但我没有看到任何变化。

【问题讨论】:

    标签: cucumber rest-assured


    【解决方案1】:

    尝试使用这样的配置:

    @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);
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2023-03-23
      • 2017-07-31
      • 2018-01-12
      • 1970-01-01
      • 2011-01-16
      • 2012-08-17
      相关资源
      最近更新 更多