I have been searching about similar problem, because I need to serve angular application on local domain like as example.com as securely.
To create certificate,
openssl req -newkey rsa:2048 -x509 -nodes -keyout server.key -new -out server.crt -config ./openssl-custom.cnf -sha256 -days 3650
openss-custom.cnf
[req]default_bits = 2048prompt = nodefault_md = sha256x509_extensions = v3_reqdistinguished_name = dn[dn]C = TRST = AnkaraL = AnkaraO = ExampleOU = AngularemailAddress = angular@example.comCN = *.example.com[v3_req]subjectAltName = @alt_names[alt_names]DNS.1 = *.example.com
Evenif I import this certificate to cacerts of the active jre, Spring boot application didn't work properly. And "trustAnchor must be non empty" error was throwed. Because jvm didn't contain my truststore. To solve this problem, truststore should be given to jvm parameter.
Set this parameters at spring boot side
@Configurationpublic class SSLConfig { @Autowired private Environment env; @PostConstruct private void configureSSL() { //load the 'javax.net.ssl.trustStore' and //'javax.net.ssl.trustStorePassword' from application.properties System.setProperty("javax.net.ssl.trustStore", env.getProperty("server.ssl.trust-store")); System.setProperty("javax.net.ssl.trustStorePassword",env.getProperty("server.ssl.trust-store-password")); }}application.properties:server.ssl.trust-store: YOUR_TRUST_STORE_PATHserver.ssl.trust-store-password: YOUR_TRUST_STORE_PASSWORD
or set jvm parameter when run java application
-Djavax.net.ssl.trustStore-Djavax.net.ssl.trustStorePassword