简体   繁体   English

放心地拒绝连接以进行HTTPS请求

[英]Connection refused in rest assured for HTTPS request

I am trying to test a REST API having an ELB similar to below: https://systemtest-inventory.com/v1/inventory/getInventory 我正在尝试测试具有类似于下面的ELB的REST API: https : //systemtest-inventory.com/v1/inventory/getInventory

When I tried the URL with postman chrome, it is giving me valid response. 当我尝试使用邮递员Chrome浏览器访问URL时,它给了我有效的答复。 But when I try to use it in Java program as below: 但是当我尝试在Java程序中使用它时,如下所示:

RestAssured.baseURI="https://systemtest-inventory.com/";
        RestAssured.get("v1/inventory/getInventory").then().assertThat().contentType(ContentType.JSON);

It gives this error: 它给出了这个错误:

org.apache.http.conn.HttpHostConnectException: Connection to https://systemtest-inventory.com refused org.apache.http.conn.HttpHostConnectException:拒绝连接到https://systemtest-inventory.com

I am aware that I am using HTTPS and need to have security certificate trusted. 我知道我正在使用HTTPS,并且需要信任安全证书。 However, I am not sure how to do it. 但是,我不确定该怎么做。 Is there any way in Rest assured to test with HTTPS and not HTTP. 请放心,有什么方法可以使用HTTPS而不是HTTP进行测试。

您可以采取以下措施来忽略HTTPS验证:

given().config(RestAssured.config().sslConfig( new SSLConfig().relaxedHTTPSValidation());

要忽略HTTPS连接,可以使用:

RestAssured.useRelaxedHTTPSValidation();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM