2

我正在尝试在 Java 8 上使用 Jetty 9.4.x 使用 SSL 部署 Http2 服务器。当客户端尝试与服务器建立连接时,我收到以下错误

java.lang.IllegalStateException: Connection rejected: No ALPN Processor for sun.security.ssl.SSLEngineImpl from [o.eclipse.jetty.alpn.conscrypt.server.ConscryptServerALPNProcessor@2814b525]

Java 11 不会出现此问题,它仅特定于 Java 8。

任何帮助将不胜感激。

根据文档jetty-alpn-conscrypt-server,我已包含org.conscrypt:conscrypt-openjdk-uber

https://www.eclipse.org/jetty/documentation/9.4.x/alpn-chapter.html#alpn-conscrypt

    public class Http2Server {

      private static Server server;
      private ServerConnector connector;
      private SslContextFactory sslContextFactory;

      public static void main(String[] args) throws Exception {

        Http2Server http2Server = new Http2Server();
        http2Server.init();

        server.start();

        server.join();

      }

      public void init() throws Exception {

        sslContextFactory = buildSslContextFactory();
        QueuedThreadPool serverExecutor = new QueuedThreadPool(100);
        serverExecutor.setName("rcx-server");

        HttpConfiguration config = new HttpConfiguration();
        config.setSecureScheme("https");
        config.setSecurePort(8080);
        config.setSendXPoweredBy(false);
        config.setSendServerVersion(false);
        config.addCustomizer(new SecureRequestCustomizer());

        HttpConnectionFactory httpFactory = new HttpConnectionFactory(config);


        HTTP2ServerConnectionFactory http2Factory = new HTTP2ServerConnectionFactory(config);
        http2Factory.setMaxConcurrentStreams(10000); // XXX Needed? Configurable?

        ALPNServerConnectionFactory alpn = new ALPNServerConnectionFactory();
        alpn.setDefaultProtocol("h2");

        SslConnectionFactory scf = new SslConnectionFactory(sslContextFactory, alpn.getProtocol());

        server = new Server(serverExecutor);
        connector = new ServerConnector(server, 1, 1, scf, alpn, http2Factory, httpFactory);
        connector.setPort(8080);
        connector.setHost("0.0.0.0");
        server.addConnector(connector);

        ALPN.debug=false;

      }

      SslContextFactory buildSslContextFactory() throws Exception {
        SslContextFactory sslContextFactory = new SslContextFactory();
        sslContextFactory.setSslContext(SSLUtils.getTlsContext());
        sslContextFactory.setIncludeCipherSuites(SSLUtils.getCipherSuites());
        sslContextFactory.setIncludeProtocols(SSLUtils.getSecureProtocols());
        Security.addProvider(new OpenSSLProvider());
        sslContextFactory.setProvider("Conscrypt");
        sslContextFactory.setEndpointIdentificationAlgorithm(null);
        sslContextFactory.setCipherComparator(HTTP2Cipher.COMPARATOR);
        return sslContextFactory;
      }
    }

依赖项:

    dependencies {
        testCompile group: 'junit', name: 'junit', version: '4.12'
        compile 'org.eclipse.jetty:jetty-server:9.4.21.v20190926'
        compile 'org.eclipse.jetty:jetty-servlet:9.4.21.v20190926'
        compile 'org.eclipse.jetty:jetty-util:9.4.21.v20190926'
        compile 'org.eclipse.jetty.http2:http2-client:9.4.21.v20190926'
        compile 'org.eclipse.jetty.http2:http2-server:9.4.21.v20190926'
        compile 'org.eclipse.jetty:jetty-alpn-conscrypt-server:9.4.21.v20190926'
        compile 'org.eclipse.jetty.alpn:alpn-api:1.1.3.v20160715'
        compile 'commons-codec:commons-codec:1.13'
        compile 'org.conscrypt:conscrypt-openjdk-uber:2.2.1'

    }

日志:

    2019-10-14 19:09:04.957:INFO:oejs.Server:main: Started @911ms
    2019-10-14 19:09:04.957:DBUG:oejuc.AbstractLifeCycle:main: STARTED @912ms Server@735f7ae5{STARTED}[9.4.21.v20190926]
    2019-10-14 19:09:16.848:DBUG:oeji.ManagedSelector:rcx-server-13-acceptor-0@4883b407-ServerConnector@54a097cc{SSL,[ssl, alpn, h2, http/1.1]}{0.0.0.0:8080}: Queued change org.eclipse.jetty.io.ManagedSelector$Accept@743fb9e3 on ManagedSelector@604ed9f0{STARTED} id=0 keys=0 selected=0 updates=0
    2019-10-14 19:09:16.848:DBUG:oeji.ManagedSelector:rcx-server-13-acceptor-0@4883b407-ServerConnector@54a097cc{SSL,[ssl, alpn, h2, http/1.1]}{0.0.0.0:8080}: Wakeup on submit ManagedSelector@604ed9f0{STARTED} id=0 keys=0 selected=0 updates=1
    2019-10-14 19:09:16.849:DBUG:oeji.ManagedSelector:rcx-server-12: Selector sun.nio.ch.KQueueSelectorImpl@4d5a27bf woken with none selected
    2019-10-14 19:09:16.850:DBUG:oeji.ManagedSelector:rcx-server-12: Selector sun.nio.ch.KQueueSelectorImpl@4d5a27bf woken up from select, 0/0/0 selected
    2019-10-14 19:09:16.850:DBUG:oeji.ManagedSelector:rcx-server-12: Selector sun.nio.ch.KQueueSelectorImpl@4d5a27bf processing 0 keys, 1 updates
    2019-10-14 19:09:16.850:DBUG:oeji.ManagedSelector:rcx-server-12: updateable 1
    2019-10-14 19:09:16.850:DBUG:oeji.ManagedSelector:rcx-server-12: update org.eclipse.jetty.io.ManagedSelector$Accept@743fb9e3
    2019-10-14 19:09:16.850:DBUG:oejut.QueuedThreadPool:rcx-server-12: queue org.eclipse.jetty.io.ManagedSelector$Accept@743fb9e3 startThread=0
    2019-10-14 19:09:16.851:DBUG:oeji.ManagedSelector:rcx-server-12: updates 0
    2019-10-14 19:09:16.851:DBUG:oeji.ManagedSelector:rcx-server-12: Selector sun.nio.ch.KQueueSelectorImpl@4d5a27bf waiting with 1 keys
    2019-10-14 19:09:16.854:DBUG:oejut.QueuedThreadPool:rcx-server-11: run org.eclipse.jetty.io.ManagedSelector$Accept@743fb9e3 in QueuedThreadPool[rcx-server]@29444d75{STARTED,8<=8<=100,i=5,r=8,q=0}[ReservedThreadExecutor@3a82f6ef{s=0/8,p=0}]
    2019-10-14 19:09:16.866:DBUG:oeji.IdleTimeout:rcx-server-11: SocketChannelEndPoint@298ca2dc{/0:0:0:0:0:0:0:1:51427<->/0:0:0:0:0:0:0:1:8080,OPEN,fill=-,flush=-,to=8/30000}{io=0/0,kio=0,kro=0}-><null> idle timeout check, elapsed: 7 ms, remaining: 29993 ms
    2019-10-14 19:09:16.869:DBUG:oejus.SslContextFactory:rcx-server-11: Customize 7bec34ca[SSLEngine[hostname=0:0:0:0:0:0:0:1 port=51427] SSL_NULL_WITH_NULL_NULL]
    2019-10-14 19:09:16.880:DBUG:oejas.ALPNServerConnectionFactory:rcx-server-11: No ALPNProcessor: 7bec34ca[SSLEngine[hostname=0:0:0:0:0:0:0:1 port=51427] SSL_NULL_WITH_NULL_NULL] DecryptedEndPoint@6907452f{/0:0:0:0:0:0:0:1:51427<->/0:0:0:0:0:0:0:1:8080,OPEN,fill=-,flush=-,to=4/30000}
    2019-10-14 19:09:16.880:DBUG:oeji.ManagedSelector:rcx-server-11: 
    java.lang.IllegalStateException: Connection rejected: No ALPN Processor for sun.security.ssl.SSLEngineImpl from [org.eclipse.jetty.alpn.conscrypt.server.ConscryptServerALPNProcessor@96532d6]
        at org.eclipse.jetty.alpn.server.ALPNServerConnectionFactory.newServerConnection(ALPNServerConnectionFactory.java:111)
        at org.eclipse.jetty.server.NegotiatingServerConnectionFactory.newConnection(NegotiatingServerConnectionFactory.java:108)
        at org.eclipse.jetty.server.SslConnectionFactory.newConnection(SslConnectionFactory.java:115)
        at org.eclipse.jetty.server.ServerConnector$ServerConnectorManager.newConnection(ServerConnector.java:549)
        at org.eclipse.jetty.io.ManagedSelector.createEndPoint(ManagedSelector.java:271)
        at org.eclipse.jetty.io.ManagedSelector.access$1800(ManagedSelector.java:62)
        at org.eclipse.jetty.io.ManagedSelector$Accept.run(ManagedSelector.java:759)
        at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:782)
        at org.eclipse.jetty.util.thread.QueuedThreadPool$Runner.run(QueuedThreadPool.java:914)
        at java.lang.Thread.run(Thread.java:748)
    2019-10-14 19:09:16.883:WARN:oeji.ManagedSelector:rcx-server-11: java.lang.IllegalStateException: Connection rejected: No ALPN Processor for sun.security.ssl.SSLEngineImpl from [org.eclipse.jetty.alpn.conscrypt.server.ConscryptServerALPNProcessor@96532d6]
    2019-10-14 19:09:16.883:DBUG:oeji.ManagedSelector:rcx-server-11: 
    java.lang.IllegalStateException: Connection rejected: No ALPN Processor for sun.security.ssl.SSLEngineImpl from [org.eclipse.jetty.alpn.conscrypt.server.ConscryptServerALPNProcessor@96532d6]
        at org.eclipse.jetty.alpn.server.ALPNServerConnectionFactory.newServerConnection(ALPNServerConnectionFactory.java:111)
        at org.eclipse.jetty.server.NegotiatingServerConnectionFactory.newConnection(NegotiatingServerConnectionFactory.java:108)
        at org.eclipse.jetty.server.SslConnectionFactory.newConnection(SslConnectionFactory.java:115)
        at org.eclipse.jetty.server.ServerConnector$ServerConnectorManager.newConnection(ServerConnector.java:549)
        at org.eclipse.jetty.io.ManagedSelector.createEndPoint(ManagedSelector.java:271)
        at org.eclipse.jetty.io.ManagedSelector.access$1800(ManagedSelector.java:62)
        at org.eclipse.jetty.io.ManagedSelector$Accept.run(ManagedSelector.java:759)
        at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:782)
        at org.eclipse.jetty.util.thread.QueuedThreadPool$Runner.run(QueuedThreadPool.java:914)
        at java.lang.Thread.run(Thread.java:748)
    2019-10-14 19:09:16.883:DBUG:oejut.QueuedThreadPool:rcx-server-11: ran org.eclipse.jetty.io.ManagedSelector$Accept@743fb9e3 in QueuedThreadPool[rcx-server]@29444d75{STARTED,8<=8<=100,i=5,r=8,q=0}[ReservedThreadExecutor@3a82f6ef{s=0/8,p=0}]
4

0 回答 0