commit
b719d7e78d
|
@ -46,16 +46,11 @@ public class RestClientLiveManualTest {
|
||||||
// old httpClient will throw UnsupportedOperationException
|
// old httpClient will throw UnsupportedOperationException
|
||||||
@Ignore
|
@Ignore
|
||||||
@Test
|
@Test
|
||||||
public final void givenAcceptingAllCertificates_whenHttpsUrlIsConsumed_thenException_1() throws GeneralSecurityException {
|
public final void givenAcceptingAllCertificates_whenHttpsUrlIsConsumed_thenOk_1() throws GeneralSecurityException {
|
||||||
final HttpComponentsClientHttpRequestFactory requestFactory = new HttpComponentsClientHttpRequestFactory();
|
final HttpComponentsClientHttpRequestFactory requestFactory = new HttpComponentsClientHttpRequestFactory();
|
||||||
final CloseableHttpClient httpClient = (CloseableHttpClient) requestFactory.getHttpClient();
|
final CloseableHttpClient httpClient = (CloseableHttpClient) requestFactory.getHttpClient();
|
||||||
|
|
||||||
final TrustStrategy acceptingTrustStrategy = new TrustStrategy() {
|
final TrustStrategy acceptingTrustStrategy = (cert, authType) -> true;
|
||||||
@Override
|
|
||||||
public final boolean isTrusted(final X509Certificate[] certificate, final String authType) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
final SSLSocketFactory sf = new SSLSocketFactory(acceptingTrustStrategy, ALLOW_ALL_HOSTNAME_VERIFIER);
|
final SSLSocketFactory sf = new SSLSocketFactory(acceptingTrustStrategy, ALLOW_ALL_HOSTNAME_VERIFIER);
|
||||||
httpClient.getConnectionManager().getSchemeRegistry().register(new Scheme("https", 8443, sf));
|
httpClient.getConnectionManager().getSchemeRegistry().register(new Scheme("https", 8443, sf));
|
||||||
|
|
||||||
|
@ -65,7 +60,7 @@ public class RestClientLiveManualTest {
|
||||||
|
|
||||||
// new httpClient : 4.4 and above
|
// new httpClient : 4.4 and above
|
||||||
@Test
|
@Test
|
||||||
public final void givenAcceptingAllCertificates_whenHttpsUrlIsConsumed_thenException_2() throws GeneralSecurityException {
|
public final void givenAcceptingAllCertificates_whenHttpsUrlIsConsumed_thenOk_2() throws GeneralSecurityException {
|
||||||
|
|
||||||
final TrustStrategy acceptingTrustStrategy = (cert, authType) -> true;
|
final TrustStrategy acceptingTrustStrategy = (cert, authType) -> true;
|
||||||
final SSLContext sslContext = SSLContexts.custom().loadTrustMaterial(null, acceptingTrustStrategy).build();
|
final SSLContext sslContext = SSLContexts.custom().loadTrustMaterial(null, acceptingTrustStrategy).build();
|
||||||
|
|
Loading…
Reference in New Issue