alibaba / nacos

an easy-to-use dynamic service discovery, configuration and service management platform for building cloud native applications.
https://nacos.io
Apache License 2.0
29.99k stars 12.8k forks source link

2.3.2版本如何给console设置https #12528

Closed ming135 closed 2 weeks ago

ming135 commented 3 weeks ago

您好: 我在application.properties里面添加如下和tls相关的配置: nacos.remote.server.rpc.tls.enable=true nacos.remote.server.rpc.tls.certChainFile=/home/nacos/certs/tls.crt nacos.remote.server.rpc.tls.certPrivateKey=/home/nacos/certs/tls.key server.port=8848 server.ssl.enabled=true server.ssl.key-store-file=/tmp/certs/nacos.jks server.ssl.key-store-type=JKS server.ssl.key-store-password=123123

报错信息如下: org.springframework.context.ApplicationContextException: Unable to start web server; nested exception is org.springframework.boot.web.server.WebServerException: Could not load key store 'null' at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.onRefresh(ServletWebServerApplicationContext.java:165) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:585) at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:147) at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:732) at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:409) at org.springframework.boot.SpringApplication.run(SpringApplication.java:308) at org.springframework.boot.SpringApplication.run(SpringApplication.java:1300) at org.springframework.boot.SpringApplication.run(SpringApplication.java:1289) at com.alibaba.nacos.Nacos.main(Nacos.java:48) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:49) at org.springframework.boot.loader.Launcher.launch(Launcher.java:108) at org.springframework.boot.loader.Launcher.launch(Launcher.java:58) at org.springframework.boot.loader.PropertiesLauncher.main(PropertiesLauncher.java:467) Caused by: org.springframework.boot.web.server.WebServerException: Could not load key store 'null' at org.springframework.boot.web.embedded.tomcat.SslConnectorCustomizer.configureSslKeyStore(SslConnectorCustomizer.java:154) at org.springframework.boot.web.embedded.tomcat.SslConnectorCustomizer.configureSsl(SslConnectorCustomizer.java:103) at org.springframework.boot.web.embedded.tomcat.SslConnectorCustomizer.customize(SslConnectorCustomizer.java:61) at org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory.customizeSsl(TomcatServletWebServerFactory.java:366) at org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory.customizeConnector(TomcatServletWebServerFactory.java:343) at org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory.getWebServer(TomcatServletWebServerFactory.java:203) at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.createWebServer(ServletWebServerApplicationContext.java:184) at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.onRefresh(ServletWebServerApplicationContext.java:162) ... 16 common frames omitted Caused by: java.lang.IllegalArgumentException: Resource location must not be null at org.springframework.util.Assert.notNull(Assert.java:201) at org.springframework.util.ResourceUtils.getURL(ResourceUtils.java:130) at org.springframework.boot.web.embedded.tomcat.SslConnectorCustomizer.configureSslKeyStore(SslConnectorCustomizer.java:151)

麻烦知道如何配置的大佬帮忙解答下,非常感谢!

karsonto commented 3 weeks ago

添加以下配置可以使用https

server.ssl.enabled=true server.ssl.key-store-type=JKS server.ssl.key-store=/xxxx.jks server.ssl.key-store-password=xxxx server.ssl.key-alias=xxxx

KomachiSion commented 3 weeks ago

可以尝试一下@karsonto的回答,

也可以自行检索 spring boot + tomcat 打开ssl(https)然后尝试。

Nacos的console即使一个纯粹的spring boot + tomcat 容器,只需要按照spring boot + tomcat 方式设置和打开ssl即可。

KomachiSion commented 2 weeks ago

No more response from author for a long time, and this problem seems usage problem.