私はhttps://ec2-52-57-54-142.eu-central-1.compute.amazonaws.com/にhttp2サーバを持っており、自己署名証明書を持っています。そして、私は、単純に物事を投稿する桟橋http2クライアントを持っています。何らかの理由で、自己署名証明書を無視しているわけではありません。ここで私は接続オブジェクトのいずれかでNOT_HANDSHAKEについて何かを参照してください、関連するコードJetty http2クライアントが自己署名証明書を無視する
SslContextFactory factory = new SslContextFactory(true);
factory.setTrustAll(true);
factory.setValidateCerts(false);
factory.setValidatePeerCerts(false);
factory.setEndpointIdentificationAlgorithm(null);
SSLContext sslContext = factory.getSslContext();
if(null == sslContext) {
sslContext = SSLContext.getInstance("TLS");
}
TrustManager[] verifiers = new TrustManager[] {...// some dummy trust manager that always passes};
sslContext.init(null, verifiers, null);
factory.setSslContext(sslContext);
HttpClientTransportOverHTTP2 httpClientTransportOverHTTP2
= new HttpClientTransportOverHTTP2(new HTTP2Client());
HttpClient httpClient = new HttpClient(httpClientTransportOverHTTP2, factory);
Request request = httpClient.POST(destination);
ContentProvider contentProvider = new InputStreamContentProvider(new StringInputStream(payload));
request.content(contentProvider);
ContentResponse response = request.send();
の抜粋ですそして、私は、デバッガで物事をステップ実行すると、私はこれらのスタックトレース
Caused by: java.util.concurrent.ExecutionException: java.nio.channels.ClosedChannelException
at org.eclipse.jetty.client.util.FutureResponseListener.getResult(FutureResponseListener.java:118)
at org.eclipse.jetty.client.util.FutureResponseListener.get(FutureResponseListener.java:101)
at org.eclipse.jetty.client.HttpRequest.send(HttpRequest.java:652)
at my code
... 34 more
Caused by: java.nio.channels.ClosedChannelException
at org.eclipse.jetty.io.WriteFlusher.onClose(WriteFlusher.java:498)
at org.eclipse.jetty.io.ssl.SslConnection$DecryptedEndPoint.onIncompleteFlush(SslConnection.java:409)
at org.eclipse.jetty.io.AbstractEndPoint$2.onIncompleteFlush(AbstractEndPoint.java:54)
at org.eclipse.jetty.io.WriteFlusher.write(WriteFlusher.java:322)
at org.eclipse.jetty.io.AbstractEndPoint.write(AbstractEndPoint.java:140)
at org.eclipse.jetty.http2.HTTP2Flusher.process(HTTP2Flusher.java:243)
at org.eclipse.jetty.util.IteratingCallback.processing(IteratingCallback.java:241)
at org.eclipse.jetty.util.IteratingCallback.succeeded(IteratingCallback.java:365)
at org.eclipse.jetty.http2.HTTP2Flusher.succeeded(HTTP2Flusher.java:258)
at org.eclipse.jetty.io.WriteFlusher$PendingState.complete(WriteFlusher.java:269)
at org.eclipse.jetty.io.WriteFlusher.completeWrite(WriteFlusher.java:394)
at org.eclipse.jetty.io.ssl.SslConnection$1.run(SslConnection.java:101)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:671)
at org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:589)
... 1 more
を取得します。
私は本当に何かを確認する気にしません。 HTTP2/TLS経由で接続したいだけです。私はさまざまな用語を探しましたが、それらはすべて同じである(setTrustAll、カスタムTrustManagerなど)で終わります。
助けが必要ですか?ありがとう!
P.S. Jettyバージョン9.3.12
あなたのopenjdkバージョンに適した 'alpn-boot.jar'をセットアップしましたか(https://www.eclipse.org/jetty/documentation/current/alpn-chapter.html#alpn-versions)( '-Xbootclasspath'で)? –
はい。同じコードは、別のhttp2サーバーであるCA – ChoChoPK
によって証明された証明書を持つ既知のhttp2サーバーで動作します。そして誰も信じようとしてゴミを取り除く – ChoChoPK