(1)生成SSL证书文件
使用jdk keytool生成证书
keytool -genkey -alias test -keypass 1234qwer -keyalg RSA -sigalg sha256withrsa -keysize 1024 -validity 365 -keystore ./localhost.jks
使用管理员账号操作,其中密钥库口令是1qaz2wsx
其中localhost.jks是生成的证书文件
(2)Spring Boot项目
TestController类
package cn.hwd.controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping("test")
public class TestController {
@RequestMapping(value = "f1", method = RequestMethod.GET)
public String f1() {
return "hello world";
}
}
TomcatServerCustomer类