[英]Connection refused in rest assured for HTTPS request
我正在嘗試測試具有類似於下面的ELB的REST API: https : //systemtest-inventory.com/v1/inventory/getInventory
當我嘗試使用郵遞員Chrome瀏覽器訪問URL時,它給了我有效的答復。 但是當我嘗試在Java程序中使用它時,如下所示:
RestAssured.baseURI="https://systemtest-inventory.com/";
RestAssured.get("v1/inventory/getInventory").then().assertThat().contentType(ContentType.JSON);
它給出了這個錯誤:
org.apache.http.conn.HttpHostConnectException:拒絕連接到https://systemtest-inventory.com
我知道我正在使用HTTPS,並且需要信任安全證書。 但是,我不確定該怎么做。 請放心,有什么方法可以使用HTTPS而不是HTTP進行測試。
您可以采取以下措施來忽略HTTPS驗證:
given().config(RestAssured.config().sslConfig( new SSLConfig().relaxedHTTPSValidation());
要忽略HTTPS連接,可以使用:
RestAssured.useRelaxedHTTPSValidation();
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.