enable https for spring boot rest application -


how enable spring boot application accessible when deployed https? found solution says add following application-config.xml file

   <security:http auto-config="true" create-session="stateless">          <security:intercept-url pattern="/**" access="role_user"                  requires-channel="https" />                                 <security:http-basic />    </security:http> 

i don't have file except web.xml;

<?xml version="1.0" encoding="utf-8"?>   <web-app xmlns:xsi="http://www.w3.org/2001/xmlschema-instance"         xmlns:web="http://java.sun.com/xml/ns/javaee"  xmlns=" http://java.sun.com/xml/ns/javaee"xsi:schemalocation="http://java.sun.com/ xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" version="3.0">  <context-param> <param-name>contextconfiglocation</param-name> <param-value>/web-inf/spring/root-context.xml,     /web-inf/spring/appservlet/servlet-context.xml</param-value> </context-param> <listener> <listener-class>org.springframework.web.context.contextloaderlistener </listener- class>  </listener> <listener> <listener-class>     org.springframework.web.context.request.requestcontextlistener </listener-class> </listener> <servlet> <servlet-name>api</servlet-name> <servlet-class>org.springframework.web.servlet.dispatcherservlet</servlet-class> <init-param>   <param-name>contextconfiglocation</param-name>   <param-value>/web-inf/spring/appservlet/servlet-context.xml</param-value> </init-param> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>api</servlet-name> <url-pattern>/</url-pattern> </servlet-mapping> <context-param> <param-name>defaulthtmlescape</param-name> <param-value>true</param-value> </context-param> <filter> <filter-name>springsecurityfilterchain</filter-name> <filter-class>               org.springframework.web.filter.delegatingfilterproxy     </filter-class> </filter> <filter-mapping> <filter-name>springsecurityfilterchain</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> 

spring boot support ssl configuration properties (in application.yaml|.properties)

server.port=8443 server.ssl.key-store=classpath:keystore.jks server.ssl.key-store-password=secret server.ssl.key-password=another-secret 

you can same thing using tomcatembeddedservletcontainerfactory.

documentation


Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

How to get the ip address of VM and use it to configure SSH connection dynamically in Ansible -

javascript - Get parameter of GET request -