- Spring Boot - Google OAuth2 Sign-In
- Spring Boot - Google Cloud Platform
- Spring Boot - OAuth2 with JWT
- Securing Web Applications
- Spring Boot - Database Handling
- Rest Controller Unit Test
- Spring Boot - Unit Test Cases
- Spring Boot - Twilio
- Spring Boot - Apache Kafka
- Spring Boot - Batch Service
- Spring Boot - Web Socket
- Spring Boot - Hystrix
- Spring Boot - Sending Email
- Spring Boot - Flyway Database
- Tracing Micro Service Logs
- Spring Boot - Creating Docker Image
- Spring Boot - Enabling Swagger2
- Spring Boot - Admin Client
- Spring Boot - Admin Server
- Spring Boot - Actuator
- Spring Cloud Configuration Client
- Spring Cloud Configuration Server
- Zuul Proxy Server and Routing
- Service Registration with Eureka
- Spring Boot - Eureka Server
- Spring Boot - Enabling HTTPS
- Spring Boot - Scheduling
- Spring Boot - Internationalization
- Spring Boot - CORS Support
- Consuming RESTful Web Services
- Spring Boot - Thymeleaf
- Spring Boot - Service Components
- Spring Boot - File Handling
- Spring Boot - Rest Template
- Spring Boot - Tomcat Port Number
- Spring Boot - Servlet Filter
- Spring Boot - Interceptor
- Spring Boot - Exception Handling
- Building RESTful Web Services
- Spring Boot - Logging
- Spring Boot - Application Properties
- Spring Boot - Runners
- Spring Beans & Dependency Injection
- Spring Boot - Code Structure
- Spring Boot - Build Systems
- Spring Boot - Tomcat Deployment
- Spring Boot - Bootstrapping
- Spring Boot - Quick Start
- Spring Boot - Introduction
- Spring Boot - Home
Spring Boot Resources
Selected Reading
- Who is Who
- Computer Glossary
- HR Interview Questions
- Effective Resume Writing
- Questions and Answers
- UPSC IAS Exams Notes
Spring Boot - Enabpng HTTPS
By default, Spring Boot apppcation uses HTTP 8080 port when the apppcation starts up.
You need to follow the steps given below to configure the HTTPS and the port 443 in Spring Boot apppcation −
Obtain the SSL certificate – Create a self-signed certificate or get one from a Certificate Authority
Enable HTTPS and 443 port
Self-Signed Certificate
To create a self-signed certificate, Java Run Time environment comes bundled with certificate management utipty key tool. This utipty tool is used to create a Self-Signed certificate. It is shown in the code given here −
keytool -genkey -apas tomcat -storetype PKCS12 -keyalg RSA -keysize 2048 -keystore keystore.p12 -vapdity 3650 Enter keystore password: Re-enter new password: What is your first and last name? [Unknown]: What is the name of your organizational unit? [Unknown]: What is the name of your organization? [Unknown]: What is the name of your City or Locapty? [Unknown]: What is the name of your State or Province? [Unknown]: What is the two-letter country code for this unit? [Unknown]: Is CN = Unknown, OU=Unknown, O = Unknown, L = Unknown, ST = Unknown, C = Unknown correct? [no]: yes
This code will generate a PKCS12 keystore file named as keystore.p12 and the certificate apas name is tomcat.
Configure HTTPS
We need to provide the server port as 443, key-store file path, key-store-password, key-store-type and key apas name into the apppcation.properties file. Observe the code given here −
server.port: 443 server.ssl.key-store: keystore.p12 server.ssl.key-store-password: springboot server.ssl.keyStoreType: PKCS12 server.ssl.keyApas: tomcat
You can use the following code if you are using YAML properties use below apppcation.yml −
server: port: 443 ssl: key-store: keystore.p12 key-store-password: springboot keyStoreType: PKCS12 keyApas: tomcat
You can create an executable JAR file, and run the spring boot apppcation by using the following Maven or Gradle commands.
For Maven, you can use the following command −
mvn clean install
After “BUILD SUCCESS”, you can find the JAR file under the target directory.
For Gradle, you can use the command
gradle clean build
After “BUILD SUCCESSFUL”, you can find the JAR file under the build/pbs directory.
Now, run the JAR file by using the following command −
java –jar <JARFILE>
Now, the apppcation has started on the Tomcat port 443 with https as shown −
Advertisements