我正在尝试使用 RestAssured 通过公司代理访问托管在 AWS 中的宁静服务,但得到 javax.net.ssl.SSLException: Unrecognized SSL message, plaintext connection? 有人可以帮助确定解决此问题需要做些什么吗
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;
import static io.restassured.RestAssured.*;
import io.restassured.RestAssured;
import io.restassured.builder.RequestSpecBuilder;
import io.restassured.response.Response;
import io.restassured.specification.RequestSpecification;
public class Rough {
@BeforeTest
public void setup() {
RestAssured.proxy("proxy.abc.com", 8080,"https");
RestAssured.useRelaxedHTTPSValidation("SSL");
}
@Test
public void testService() {
String apiURL = "https://api-aws-cs-dev.abc.com/cs/customer/v1/accountservices/public/preload";
String apiBody = "{}";
RequestSpecBuilder requestSpecBuilder = new RequestSpecBuilder();
requestSpecBuilder.setBody(apiBody);
requestSpecBuilder.addHeader("Content-Type", "application/json");
requestSpecBuilder.addHeader("Accept", "application/json");
requestSpecBuilder.addQueryParam("version", "1");
RequestSpecification requestSpecification = requestSpecBuilder.build();
Response r = given().log().everything().spec(requestSpecification).post(apiURL);
System.out.println(r.getBody().prettyPrint());
}
}
例外 :
javax.net.ssl.SSLException: Unrecognized SSL message, plaintext connection?
at sun.security.ssl.InputRecord.handleUnknownRecord(InputRecord.java:710)
at sun.security.ssl.InputRecord.read(InputRecord.java:527)
at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:983)
~谢谢