How to set TLS version in Apache HttpClient 4.5.x
up vote
0
down vote
favorite
I've been exploring for a way to change the TLS version when using Apache HttpClient, and looking at many examples provided, the version that's used is always TLSv1.2
instead of TLSv1.1
.
//Set the https use TLSv1.1
private static Registry<ConnectionSocketFactory> getRegistry() throws KeyManagementException, NoSuchAlgorithmException {
SSLContext sslContext = SSLContexts.custom().build();
SSLConnectionSocketFactory sslConnectionSocketFactory = new SSLConnectionSocketFactory(sslContext,
new String{"TLSv1.1"}, null, SSLConnectionSocketFactory.getDefaultHostnameVerifier());
return RegistryBuilder.<ConnectionSocketFactory>create()
.register("http", PlainConnectionSocketFactory.getSocketFactory())
.register("https", sslConnectionSocketFactory)
.build();
}
public static void main(String... args) {
try {
//Set the https use TLSv1.1
PoolingHttpClientConnectionManager clientConnectionManager = new PoolingHttpClientConnectionManager(getRegistry());
clientConnectionManager.setMaxTotal(100);
clientConnectionManager.setDefaultMaxPerRoute(20);
HttpClient client = HttpClients.custom().setConnectionManager(clientConnectionManager).build();
} catch (KeyManagementException | NoSuchAlgorithmException e) {
e.printStackTrace();
}
}
However after testing, my TLS version is still TLSv1.2 (TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384)
when it sent the request instead of TLSv1.1
.
Thanks.
java apache httpclient tls1.2
add a comment |
up vote
0
down vote
favorite
I've been exploring for a way to change the TLS version when using Apache HttpClient, and looking at many examples provided, the version that's used is always TLSv1.2
instead of TLSv1.1
.
//Set the https use TLSv1.1
private static Registry<ConnectionSocketFactory> getRegistry() throws KeyManagementException, NoSuchAlgorithmException {
SSLContext sslContext = SSLContexts.custom().build();
SSLConnectionSocketFactory sslConnectionSocketFactory = new SSLConnectionSocketFactory(sslContext,
new String{"TLSv1.1"}, null, SSLConnectionSocketFactory.getDefaultHostnameVerifier());
return RegistryBuilder.<ConnectionSocketFactory>create()
.register("http", PlainConnectionSocketFactory.getSocketFactory())
.register("https", sslConnectionSocketFactory)
.build();
}
public static void main(String... args) {
try {
//Set the https use TLSv1.1
PoolingHttpClientConnectionManager clientConnectionManager = new PoolingHttpClientConnectionManager(getRegistry());
clientConnectionManager.setMaxTotal(100);
clientConnectionManager.setDefaultMaxPerRoute(20);
HttpClient client = HttpClients.custom().setConnectionManager(clientConnectionManager).build();
} catch (KeyManagementException | NoSuchAlgorithmException e) {
e.printStackTrace();
}
}
However after testing, my TLS version is still TLSv1.2 (TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384)
when it sent the request instead of TLSv1.1
.
Thanks.
java apache httpclient tls1.2
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I've been exploring for a way to change the TLS version when using Apache HttpClient, and looking at many examples provided, the version that's used is always TLSv1.2
instead of TLSv1.1
.
//Set the https use TLSv1.1
private static Registry<ConnectionSocketFactory> getRegistry() throws KeyManagementException, NoSuchAlgorithmException {
SSLContext sslContext = SSLContexts.custom().build();
SSLConnectionSocketFactory sslConnectionSocketFactory = new SSLConnectionSocketFactory(sslContext,
new String{"TLSv1.1"}, null, SSLConnectionSocketFactory.getDefaultHostnameVerifier());
return RegistryBuilder.<ConnectionSocketFactory>create()
.register("http", PlainConnectionSocketFactory.getSocketFactory())
.register("https", sslConnectionSocketFactory)
.build();
}
public static void main(String... args) {
try {
//Set the https use TLSv1.1
PoolingHttpClientConnectionManager clientConnectionManager = new PoolingHttpClientConnectionManager(getRegistry());
clientConnectionManager.setMaxTotal(100);
clientConnectionManager.setDefaultMaxPerRoute(20);
HttpClient client = HttpClients.custom().setConnectionManager(clientConnectionManager).build();
} catch (KeyManagementException | NoSuchAlgorithmException e) {
e.printStackTrace();
}
}
However after testing, my TLS version is still TLSv1.2 (TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384)
when it sent the request instead of TLSv1.1
.
Thanks.
java apache httpclient tls1.2
I've been exploring for a way to change the TLS version when using Apache HttpClient, and looking at many examples provided, the version that's used is always TLSv1.2
instead of TLSv1.1
.
//Set the https use TLSv1.1
private static Registry<ConnectionSocketFactory> getRegistry() throws KeyManagementException, NoSuchAlgorithmException {
SSLContext sslContext = SSLContexts.custom().build();
SSLConnectionSocketFactory sslConnectionSocketFactory = new SSLConnectionSocketFactory(sslContext,
new String{"TLSv1.1"}, null, SSLConnectionSocketFactory.getDefaultHostnameVerifier());
return RegistryBuilder.<ConnectionSocketFactory>create()
.register("http", PlainConnectionSocketFactory.getSocketFactory())
.register("https", sslConnectionSocketFactory)
.build();
}
public static void main(String... args) {
try {
//Set the https use TLSv1.1
PoolingHttpClientConnectionManager clientConnectionManager = new PoolingHttpClientConnectionManager(getRegistry());
clientConnectionManager.setMaxTotal(100);
clientConnectionManager.setDefaultMaxPerRoute(20);
HttpClient client = HttpClients.custom().setConnectionManager(clientConnectionManager).build();
} catch (KeyManagementException | NoSuchAlgorithmException e) {
e.printStackTrace();
}
}
However after testing, my TLS version is still TLSv1.2 (TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384)
when it sent the request instead of TLSv1.1
.
Thanks.
java apache httpclient tls1.2
java apache httpclient tls1.2
asked Nov 21 at 10:21
ZZPLKF
1,51711524
1,51711524
add a comment |
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53409907%2fhow-to-set-tls-version-in-apache-httpclient-4-5-x%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown