In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
1. Generate SSL certificate
two。 Put the certificate under the root of the project, for example, when I installed the certificate for Anxin SSL website, it was placed in:
3. Put the certificate in the project resources directory, the same directory as application.properties, and then modify the application.properties file to add HTTPS support. Add the following code to application.properties:
Server:
Port:443 specifies the https port number
Server:
Key-store Certificate name
Key-alias alias
Key-store-type certificate type
Key-store-password certificate password
Enabled: true allows requests through https
4. Add the following code to the configuration class:
Package com.bootdo.common.config
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.ConfigurableEmbeddedServletContainer
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 HttpsConfig {
@ Bean
Public EmbeddedServletContainerFactory servletContainer () {
TomcatEmbeddedServletContainerFactory tomcat = new TomcatEmbeddedServletContainerFactory () {
@ Override
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 (getHttpConnector ())
Return tomcat
}
Private Connector getHttpConnector () {
Connector connector = new Connector ("org.apache.coyote.http11.Http11NioProtocol")
Connector.setScheme ("http")
Connector.setPort (80)
Connector.setSecure (false)
Connector.setRedirectPort (443)
Return connector
}
Public void customize (ConfigurableEmbeddedServletContainer container) {
Container.setPort (443)
}
}
5. If you upload to the server, press the certificate file in the place where the server puts the jar package:
Article source: http://baijiahao.baidu.com/builder/preview/s?id=1627774493795275221
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.