0

Java コードに http 接続プールを実装しようとしていますが、それを使用しようとするとハンドシェイク例外が発生します。接続マネージャーを設定する1行を削除すると、機能します。これは私には意味がありません。これらの jar ファイルを使用しています: httpclient-4.5.2.jar httpcore-4.4.4.jar

接続プーリングを使用すると、次のようになります。

RequestConfig requestConfig = RequestConfig.custom()
        .setConnectTimeout(10000)
        .setConnectionRequestTimeout(10000)
        .setSocketTimeout(5000)
        .build();

SSLContext sslContext = SSLContexts.custom()
        .loadKeyMaterial(readStore(), KEYSTOREPASS) 
        .build();

HttpClientConnectionManager poolingConnManager = new PoolingHttpClientConnectionManager();

httpClient = HttpClients.custom()
        .setConnectionManager(poolingConnManager)
        .setDefaultRequestConfig(requestConfig)
        .setSSLContext(sslContext)
        .build();

致命的なアラートの受信をスローします: handshake_failure例外:

main, RECV TLSv1.2 ALERT:  fatal, handshake_failure
%% Invalidated:  [Session-1, TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256]
%% Invalidated:  [Session-2, TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256]
main, called closeSocket()
main, handling exception: javax.net.ssl.SSLHandshakeException: Received fatal alert: handshake_failure
main, called close()
main, called closeInternal(true)
00:22:51,523 ERROR TestHttps:155 - Received fatal alert: handshake_failure

接続プーリングがコメントアウトされている場合:

RequestConfig requestConfig = RequestConfig.custom()
        .setConnectTimeout(10000)
        .setConnectionRequestTimeout(10000)
        .setSocketTimeout(5000)
        .build();

SSLContext sslContext = SSLContexts.custom()
        .loadKeyMaterial(readStore(), KEYSTOREPASS) // use null as second param if you don't have a separate key password
        .build();

HttpClientConnectionManager poolingConnManager = new PoolingHttpClientConnectionManager();

httpClient = HttpClients.custom()
        //.setConnectionManager(poolingConnManager)
        .setDefaultRequestConfig(requestConfig)
        .setSSLContext(sslContext)
        .build();

それは正常に動作し、私の値を返します (ここでは難読化されています):

main, READ: TLSv1.2 Application Data, length = 40
Padded plaintext after DECRYPTION:  len = 16
0000: xx xx xx xx xx xx xx xx   xx xx xx xx xx xx xx xx  1234567890
main, called close()
main, called closeInternal(true)
main, SEND TLSv1.2 ALERT:  warning, description = close_notify
Padded plaintext before ENCRYPTION:  len = 2
0000: 01 00                                              ..
main, WRITE: TLSv1.2 Alert, length = 26
[Raw write]: length = 31
0000: 15 03 03 00 1A 00 00 00   00 00 00 00 01 2C 7D 6E  .............,.n
0010: 66 04 BA 1D FF 4A EB 54   0F 60 C7 A4 41 4A 68     f....J.T.`..AJh
main, called closeSocket(true)

私は何を間違っていますか?ありがとう

4

1 に答える 1