ServerConnector 中没有 SSL 下一个协议的协议工厂:'HTTP/1.1'
No protocol factory for SSL next protocol: 'HTTP/1.1' in ServerConnector
像这样创建 Jetty ServerConnector 时:
Server server = new Server();
SslContextFactory sslContextFactory = new SslContextFactory();
ServerConnector sslConnector = new ServerConnector(server,
new SslConnectionFactory(sslContextFactory, HttpVersion.HTTP_1_1.asString()));
启动服务器时出现以下错误:
java.lang.IllegalStateException: No protocol factory for SSL next protocol: 'HTTP/1.1' in ServerConnector@37918c79{SSL,[ssl]}{0.0.0.0:7443}
at org.eclipse.jetty.server.AbstractConnector.doStart(AbstractConnector.java:278)
at org.eclipse.jetty.server.AbstractNetworkConnector.doStart(AbstractNetworkConnector.java:81)
at org.eclipse.jetty.server.ServerConnector.doStart(ServerConnector.java:235)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
at org.eclipse.jetty.server.Server.doStart(Server.java:395)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
[...]
您缺少构成 SSL+HTTP(也称为 HTTPS)的连接的 HTTP 部分。
Tip: If you don't see an HttpConfiguration
or HttpConnectionFactory
being passed into your ServerConnector
then you are not using that ServerConnector
for HTTP. (which would be the case for proxies, unixsocket, jni connectors, custom connectors, etc)
典型的设置是...
int httpsPort = 8443;
HttpConfiguration http_config = new HttpConfiguration();
http_config.setSecureScheme("https");
http_config.setSecurePort(httpsPort);
// TODO: Setup non-SSL/TLS Connector/Port here (using http_config) and
// set it to auto-redirect to SSL/TLS port.
// SSL Context Factory
SslContextFactory sslContextFactory = new SslContextFactory();
sslContextFactory.setKeyStorePath("/path/to/keystore");
sslContextFactory.setKeyStorePassword(...);
sslContextFactory.setKeyManagerPassword(...);
sslContextFactory.setTrustStorePath("/path/to/keystore");
sslContextFactory.setTrustStorePassword(...);
// SSL HTTP Configuration
HttpConfiguration https_config = new HttpConfiguration(http_config);
https_config.addCustomizer(new SecureRequestCustomizer()); // so that servlets can see the
// encryption details
// SSL Connector
ServerConnector sslConnector = new ServerConnector(server,
new SslConnectionFactory(sslContextFactory,HttpVersion.HTTP_1_1.asString()),
new HttpConnectionFactory(https_config)); // <-- the argument you were missing
sslConnector.setPort(httpsPort);
server.addConnector(sslConnector);
像这样创建 Jetty ServerConnector 时:
Server server = new Server();
SslContextFactory sslContextFactory = new SslContextFactory();
ServerConnector sslConnector = new ServerConnector(server,
new SslConnectionFactory(sslContextFactory, HttpVersion.HTTP_1_1.asString()));
启动服务器时出现以下错误:
java.lang.IllegalStateException: No protocol factory for SSL next protocol: 'HTTP/1.1' in ServerConnector@37918c79{SSL,[ssl]}{0.0.0.0:7443}
at org.eclipse.jetty.server.AbstractConnector.doStart(AbstractConnector.java:278)
at org.eclipse.jetty.server.AbstractNetworkConnector.doStart(AbstractNetworkConnector.java:81)
at org.eclipse.jetty.server.ServerConnector.doStart(ServerConnector.java:235)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
at org.eclipse.jetty.server.Server.doStart(Server.java:395)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
[...]
您缺少构成 SSL+HTTP(也称为 HTTPS)的连接的 HTTP 部分。
Tip: If you don't see an
HttpConfiguration
orHttpConnectionFactory
being passed into yourServerConnector
then you are not using thatServerConnector
for HTTP. (which would be the case for proxies, unixsocket, jni connectors, custom connectors, etc)
典型的设置是...
int httpsPort = 8443;
HttpConfiguration http_config = new HttpConfiguration();
http_config.setSecureScheme("https");
http_config.setSecurePort(httpsPort);
// TODO: Setup non-SSL/TLS Connector/Port here (using http_config) and
// set it to auto-redirect to SSL/TLS port.
// SSL Context Factory
SslContextFactory sslContextFactory = new SslContextFactory();
sslContextFactory.setKeyStorePath("/path/to/keystore");
sslContextFactory.setKeyStorePassword(...);
sslContextFactory.setKeyManagerPassword(...);
sslContextFactory.setTrustStorePath("/path/to/keystore");
sslContextFactory.setTrustStorePassword(...);
// SSL HTTP Configuration
HttpConfiguration https_config = new HttpConfiguration(http_config);
https_config.addCustomizer(new SecureRequestCustomizer()); // so that servlets can see the
// encryption details
// SSL Connector
ServerConnector sslConnector = new ServerConnector(server,
new SslConnectionFactory(sslContextFactory,HttpVersion.HTTP_1_1.asString()),
new HttpConnectionFactory(https_config)); // <-- the argument you were missing
sslConnector.setPort(httpsPort);
server.addConnector(sslConnector);