10000
We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
第一步就是用JDK的keytool工具来创建一个密钥存储(keystore) keytool -keystore mykeys.jks -genkey -alias tomcat -keyalg RSA 记住输入的Enter keystore password(该项目为letmein),剩下的一路回车,直到: Is CN=Unknown, OU=Unknown, O=Unknown, L=Unknown, ST=Unknown, C=Unknown correct? 输入yes
keytool -keystore mykeys.jks -genkey -alias tomcat -keyalg RSA
Is CN=Unknown, OU=Unknown, O=Unknown, L=Unknown, ST=Unknown, C=Unknown correct?
把证书添加到项目中 src/main/resources/mykeys.jks
src/main/resources/mykeys.jks
修改配置文件application.properties,加入如下配置
server.port= 8443 server.ssl.key-store= classpath:mykeys.jks server.ssl.key-store-password= letmein server.ssl.key-password= letmein
import org.apache.catalina.Context; import org.apache.catalina.connector.Connector; import org.apache.tomcat.util.descriptor.web.SecurityCollection; import org.apache.tomcat.util.descriptor.web.SecurityConstraint; import org.springframework.boot.context.embedded.EmbeddedServletContainerFactory; import org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @Configuration public class HttpsConfiguration { @Bean public EmbeddedServletContainerFactory servletContainer() { TomcatEmbeddedServletContainerFactory tomcat = new TomcatEmbeddedServletContainerFactory(){ protected void postProcessContext(Context context) { SecurityConstraint securityConstraint = new SecurityConstraint(); securityConstraint.setUserConstraint("CONFIDENTIAL"); SecurityCollection collection = new SecurityCollection(); collection.addPattern("/*"); securityConstraint.addCollection(collection); context.addConstraint(securityConstraint); } }; tomcat.addAdditionalTomcatConnectors(httpConnector()); return tomcat; } @Bean public Connector httpConnector(){ Connector connector = new Connector("org.apache.coyote.http11.Http11NioProtocol"); connector.setScheme("http"); connector.setPort(8080);//表示用8080端口来供http访问 connector.setSecure(false); connector.setRedirectPort(8443);//自动重定向到8443端口 return connector; } }
The text was updated successfully, but these errors were encountered:
Sorry, something went wrong.
楼主,没看懂如何生成的mykeys.jks; 我是window10系统,我s双击打开keytool.exe的时候,dos窗口一闪而过,我通过cmd命令输入 keytool -keystore mykeys.jks -genkey -alias tomcat -keyalg RSA 提示我输入密钥库口令,我输入了,这个是自己输入的一个吗? 输入这个,又提示我你的名字、国家、组织、城市。。。。。 最后不知道怎么搞了。
@AabbyAngel 密钥库随便输,记住就可以,第3步要用(server.ssl.key-store-password=密钥库),剩下的一路回车即可,最后让你确认输入的信息是否正确,输入“是”或者yes。(和我第一步的区别就是你这是中文的,我那个是英文的)
@x113773 好的,我在试试,谢谢楼主,想以后跟你一起学。
No branches or pull requests
Uh oh!
There was an error while loading. Please reload this page.
第一步就是用JDK的keytool工具来创建一个密钥存储(keystore)
keytool -keystore mykeys.jks -genkey -alias tomcat -keyalg RSA
记住输入的Enter keystore password(该项目为letmein),剩下的一路回车,直到:
Is CN=Unknown, OU=Unknown, O=Unknown, L=Unknown, ST=Unknown, C=Unknown correct?
输入yes
把证书添加到项目中
src/main/resources/mykeys.jks
修改配置文件application.properties,加入如下配置
HttpsConfiguration.java
The text was updated successfully, but these errors were encountered: