Skip to content

Commit e84000b

Browse files
authored
fixes #31 cache the SSLContext in HttpClientRequest (#32)
1 parent 26f1d4e commit e84000b

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/main/java/com/networknt/http/client/HttpClientRequest.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ public class HttpClientRequest {
3838

3939
private static final Logger logger = LoggerFactory.getLogger(HttpClientRequest.class);
4040
private static final ClientConfig clientConfig = ClientConfig.get();
41+
private static SSLContext sslContext = null;
4142
HttpClient httpClient;
4243

4344
public static final String TLS = "tls";
@@ -269,7 +270,8 @@ private HttpRequest.BodyPublisher ofFormData(Map<Object, Object> data) {
269270
*/
270271
@SuppressWarnings("unchecked")
271272
public static SSLContext createSSLContext() throws IOException {
272-
SSLContext sslContext = null;
273+
// return the cached sslContext if it is not null.
274+
if(sslContext != null) return sslContext;
273275
KeyManager[] keyManagers = null;
274276
Map<String, Object> tlsMap = clientConfig.getTlsConfig();
275277
if(tlsMap != null) {

0 commit comments

Comments
 (0)