title: How to create SSL certificate & implement in Spring Boot?
body: <p>Following spring security book, I try to create SSL certificate through the following commands but getting an error which I mention in the last. grateful for the help. I've tried openssl as well as with wimpty:</p>
  <pre><code>openssl req -newkey rsa:2048 -x509 -keyout key.pem -out cert.pem -days 365
  openssl pkcs12 -export -in cert.pem -inkey key.pem -out certificate.p12
  -name &quot;certificate&quot;
  </code></pre>
  <p>application.properties</p>
  <pre><code>server.port=8088
  server.ssl.key-store-type=PKCS12
  server.ssl.key-store=classpath:certificate.p12
  server.ssl.key-password=12345
  </code></pre>
  <p>Also, I've placed certificate.p12 under resources folder.</p>
  <p>But all efforts ending up on the following error:</p>
  <pre><code>2021-11-21 23:49:20.738  INFO 16764 --- [           main] com.kash.SpringsecurityApplication       
  : Starting SpringsecurityApplication using Java 11.0.12 on LAPTOP-BQ48GM36 with PID 16764 
  (B:\spring\springsecurity\target\classes started by The Kash in B:\spring\springsecurity)
  2021-11-21 23:49:20.742  INFO 16764 --- [           main] com.kash.SpringsecurityApplication       
  : No active profile set, falling back to default profiles: default
  2021-11-21 23:49:22.272  WARN 16764 --- [           main] 
  ConfigServletWebServerApplicationContext : Exception encountered during context initialization 
  - cancelling refresh attempt: org.springframework.context.ApplicationContextException: Unable 
  to start web server; nested exception is 
  org.springframework.boot.web.server.WebServerException: Could not load key store 
  'classpath:certificate.p12'
  2021-11-21 23:49:22.280  INFO 16764 --- [           main] 
  ConditionEvaluationReportLoggingListener : 
  
  Error starting ApplicationContext. To display the conditions report re-run your application 
  with 'debug' enabled.
  2021-11-21 23:49:22.299 ERROR 16764 --- [           main] o.s.boot.SpringApplication               
  : Application run failed
  
  org.springframework.context.ApplicationContextException: Unable to start web server; nested 
  exception is org.springframework.boot.web.server.WebServerException: Could not load key store 
  'classpath:certificate.p12'
  at g.springframework.boot.web.servlet.context.
   ServletWebServerApplicationContext.onRefresh(ServletWebServerApplicationContext.java:163) 
  ~[spring-boot-2.6.0.jar:2.6.0]
   at org.springframework.context.
   support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:577) ~[spring- 
   context-5.3.13.jar:5.3.13]
  at org.springframework.boot.web.servlet.context.
  ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:145) ~ 
  [spring-boot-2.6.0.jar:2.6.0]
  at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:730) ~[spring- 
  boot-2.6.0.jar:2.6.0]
  at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:412) ~ 
  [spring-boot-2.6.0.jar:2.6.0]
  at org.springframework.boot.SpringApplication.run(SpringApplication.java:302) ~[spring-boot- 
   2.6.0.jar:2.6.0]
  at org.springframework.boot.SpringApplication.run(SpringApplication.java:1301) ~[spring-boot- 
   2.6.0.jar:2.6.0]
  at org.springframework.boot.SpringApplication.run(SpringApplication.java:1290) ~[spring-boot- 
  2.6.0.jar:2.6.0]
  at com.kash.SpringsecurityApplication.main(SpringsecurityApplication.java:10) ~[classes/:na]
   Caused by: org.springframework.boot.web.server.WebServerException: Could not load key store 
   'classpath:certificate.p12'
      at org.springframework.boot.web.embedded.tomcat
   .SslConnectorCustomizer.configureSslKeyStore(SslConnectorCustomizer.java:132) ~[spring-boot- 
   2.6.0.jar:2.6.0]org.springframework.boot.web.embedded.tomcat.S
   at slConnectorCustomizer.configureSsl(SslConnectorCustomizer.java:92) ~[spring-boot- 
   2.6.0.jar:2.6.0]
      at org.springframework.boot.web.embedded
     .tomcat.SslConnectorCustomizer.configureSslKeyStore(SslConnectorCustomizer.java:129) ~ 
    [spring-boot-2.6.0.jar:2.6.0]
      ... 15 common frames omitted
  </code></pre>