在Jetty上配置SSL

问题描述

我正在尝试配置码头环境以能够建立安全连接

我已经执行了官方码头文件https://www.eclipse.org/jetty/documentation/9.4.31.v20200723/jetty-ssl-distribution.html中描述的步骤。但是没有成功。

重新创建步骤:

  1. java -jar start.jar --create-startd --add-to-start = ssl
  2. java -jar start.jar --add-to-start = ssl,conscrypt
  3. java -jar start.jar --add-to-startd = ssl,https
  4. 使用以下值更新start.d / ssl.ini:
--module=ssl
jetty.ssl.host=0.0.0.0
jetty.ssl.port=8583
jetty.sslContext.keyStorePath=etc/keystore
jetty.sslContext.trustStorePath=etc/keystore
jetty.sslContext.keyStorePassword=OBF:
jetty.sslContext.keyManagerPassword=OBF:
jetty.sslContext.trustStorePassword=OBF:
 #Enable client certificate authentication.
jetty.sslContext.needClientAuth=true

为了生成密钥库,我遵循以下步骤:

openssl genrsa -des3 -out jetty.key
openssl req -new -x509 -key jetty.key -out jetty.crt
keytool -keystore keystore -import -alias jetty -file jetty.crt -trustcacerts
openssl req -new -key jetty.key -out jetty.csr
openssl pkcs12 -inkey jetty.key -in jetty.crt -export -out jetty.pkcs12
keytool -importkeystore -srckeystore jetty.pkcs12 -srcstoretype PKCS12 -destkeystore keystore

在最后一步,我对密码进行了模糊处理,并将其更新为start.d / ssl.ini文件

问题

我遇到一个类似这样的错误

2020-09-28 13:51:46.896:INFO::main: Logging initialized @523ms to org.eclipse.jetty.util.log.StdErrLog
2020-09-28 13:51:47.387:WARN:oejs.HomeBaseWarning:main: This instance of Jetty is not running from a separate {jetty.base} directory,this is not recommended.  See documentation at http://www.eclipse.org/jetty/documentation/current/startup.html
2020-09-28 13:51:47.414:INFO:oejs.Server:main: jetty-9.4.31.v20200723; built: 2020-07-23T17:57:36.812Z; git: 450ba27947e13e66baa8cd1ce7e85a4461cacc1d; jvm 11.0.8+10-LTS
2020-09-28 13:51:47.460:INFO:oejdp.ScanningAppProvider:main: Deployment monitor [file:///opt/jetty-distribution-9.4.31.v20200723/webapps/] at interval 1
2020-09-28 13:51:47.796:INFO:oejus.SslContextFactory:main: x509=X509@6853425f(jetty,h=[jettyhttp2sample.organicdesign.org],w=[]) for Server@5a9f4771[provider=Conscrypt,keyStore=file:///opt/jetty-distribution-9.4.31.v20200723/etc/keystore,trustStore=file:///opt/jetty-distribution-9.4.31.v20200723/etc/keystore]
2020-09-28 13:51:47.799:INFO:oejus.SslContextFactory:main: Unable to get KeyManagerFactory instance for algorithm [SunX509] on provider [Conscrypt],using default
2020-09-28 13:51:47.882:INFO:oejs.AbstractConnector:main: Started ServerConnector@46c1a1fc{SSL,(ssl,http/1.1)}{localhost:8443}
2020-09-28 13:51:47.886:INFO:oejs.AbstractConnector:main: Started ServerConnector@7b205dbd{HTTP/1.1,(http/1.1)}{0.0.0.0:8080}
2020-09-28 13:51:47.887:INFO:oejs.Server:main: Started @1514ms

使用认设置,无法在提供程序[Conscrypt]上获取算法[SunX509]的KeyManagerFactory实例

感谢您的帮助

谢谢。

解决方法

这里没有报告错误,这是备用提供商的正常后备操作(在您的情况下进行加密)。

Conscrypt安全提供程序不支持SunX509的{​​{1}}算法,因此它可以使用JVM默认实现。

此外,请勿直接在jetty-home / jetty-distribution中编辑文件,这是一个更大的警告,请正确使用发行版,并根据链接到的文档将您的jetty-home与您的jetty-base分开。该警告消息。在Jetty 10和Jetty 11中已经完全删除了管理Jetty独立配置的古老技术!