Upgrading HTTPS Records
1. Go to Ali Cloud to purchase the certificate (free version) and submit the audit materials
Purchased certificates
2. Download the certificate
Download the certificate
3. See step 3 of the above page
JKS certificate installation
4. Run the command provided by Aliyun in the certificate directory and fill in pfX-password. TXT with the password (three times) to generate your name. JKS file.
Generate a JKS certificate
Here I’ve renamed it any.jks
5. Copy any. JKS to the Resources directory of the Spring Boot application
Mobile certificate
6. Configure the certificate and port in application.yml, and enter the password in Step 4
image.png
This configuration causes the Undertow container to listen on port 443, so you need to add https:// in front of the domain name to access the website content. Adding http:// does not work, so you need to have the Undertow container listen on port 80. In addition, all requests from port 80 are redirected to port 443 to complete the switchover from HTTP to HTTPS.
Add sslconfig. Java and configure Undertow to listen on port 80.
@Configuration public class SslConfig { @Bean public EmbeddedServletContainerFactory servletContainer() { UndertowEmbeddedServletContainerFactory undertowFactory = new UndertowEmbeddedServletContainerFactory(); undertowFactory.addBuilderCustomizers(new UndertowBuilderCustomizer() { @Override public void customize(Undertow.Builder Builder) {builder. AddHttpListener (80, "0.0.0.0"); }}); return undertowFactory; }}Copy the code
8. Configure port 80 to port 443 mapping in Spring Security
At this point, repackage the application, redistribute the application, that is, complete the UPGRADE from HTTP to HTTPS, which makes the website more secure, if you are interested in giving it a try.
© copyright belongs to the author, reprint or content cooperation please contact the author
● How does the micro-service registry carry tens of millions of visits of large systems?
Here’s how you should play it
● Spring Boot exception processing
● Spring Boot Configuration – Configuration information encryption
● Reject black box applications – Visual monitoring of Spring Boot applications
● There are three sources of concurrency bugs, so keep your eyes open
This article is published by OpenWrite!